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 <jbeich@FreeBSD.org> (downstream patch)
Reviewed by: Kenny Levinsen <kl@kl.wtf>
master
Evgeniy Khramtsov 2021-11-28 19:38:16 +03:00 committed by Kenny Levinsen
parent f32f6963b9
commit 601dfc87ff
1 changed files with 6 additions and 1 deletions

7
main.c
View File

@ -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;
}