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
parent
f32f6963b9
commit
601dfc87ff
7
main.c
7
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) {
|
if (strptime(s, "%H:%M", &tm) == NULL) {
|
||||||
return -1;
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue