commit: e6b939494b67612367eabf8bf9a22de1c8220daf
parent de43dbe2d573e783cb1a7d83e1b1de3af77d72b7
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Fri, 29 Mar 2024 02:07:43 +0100
lib/iso_parse: Correctly initialize struct tm
Most notably, tm.tm_isdst shouldn't be initialised to zero but -1.
Diffstat:
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/lib/iso_parse.c b/lib/iso_parse.c
@@ -37,8 +37,15 @@ iso_parse(char *arg, char **errstr)
return time;
}
- struct tm tm;
- memset(&tm, 0, sizeof(tm));
+ struct tm tm = {
+ .tm_year = 0,
+ .tm_mon = 0,
+ .tm_mday = 0,
+ .tm_hour = 0,
+ .tm_min = 0,
+ .tm_sec = 0,
+ .tm_isdst = -1, // unknown if DST is in effect
+ };
// No %F in POSIX
char *s = strptime(arg, "%Y-%m-%d", &tm);