From 601dfc87ff6ef0f14e3a56bef35d876135ffc937 Mon Sep 17 00:00:00 2001 From: Evgeniy Khramtsov <2khramtsov@gmail.com> Date: Sun, 28 Nov 2021 19:38:16 +0300 Subject: [PATCH] main.c: define timezone to tm.tm_gmtoff on FreeBSD FreeBSD has BSD extension timezone, which conflicts with XSI extension with the same name, according to time.h: char *timezone(int, int); /* XXX XSI conflict */ ... FreeBSD also has long tm_gmtoff member of struct tm, which is offset from UTC in seconds, according to time.h: struct tm { ... long tm_gmtoff; /* offset from UTC in seconds */ char *tm_zone; /* timezone abbreviation */ } which is the same as XSI extension timezone. Co-authored-by: Jan Beich (downstream patch) Reviewed by: Kenny Levinsen --- main.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 1042d17..38e0faa 100644 --- a/main.c +++ b/main.c @@ -707,7 +707,12 @@ static int parse_time_of_day(const char *s, time_t *time) { if (strptime(s, "%H:%M", &tm) == NULL) { return -1; } - *time = tm.tm_hour * 3600 + tm.tm_min * 60 + timezone; + *time = tm.tm_hour * 3600 + tm.tm_min * 60; +#if defined(__FreeBSD__) + *time += tm.tm_gmtoff; +#else + *time += timezone; +#endif return 0; }