summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2020-02-12 12:23:46 -0500
committerTavian Barnes <tavianator@tavianator.com>2020-02-12 12:23:46 -0500
commit2bdd2d12801eada77945d4f6644248cf7952cc64 (patch)
treec7a2470fce314bb6abf4c396c2f6a110b11abed1
parent60a33ca726518a3325e56d77f65bfdcbecf91444 (diff)
downloadbfs-2bdd2d12801eada77945d4f6644248cf7952cc64.tar.xz
parse: Work around missing `timezone` on FreeBSD
FreeBSD has a function timezone() that conflicts with the global variable, despite that being specified by POSIX. Use tm_gmtoff instead.
-rw-r--r--parse.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/parse.c b/parse.c
index 373f7c2..16d0c96 100644
--- a/parse.c
+++ b/parse.c
@@ -1787,8 +1787,13 @@ invalid:
fprintf(stderr, " - %04d-%02d-%02d\n", year, month, tm.tm_mday);
fprintf(stderr, " - %04d-%02d-%02dT%02d:%02d:%02d\n", year, month, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
+#if __FreeBSD__
+ tz_hour = tm.tm_gmtoff/3600;
+ tz_min = (labs(tm.tm_gmtoff)/60)%60;
+#else
tz_hour = -timezone/3600;
tz_min = (labs(timezone)/60)%60;
+#endif
fprintf(stderr, " - %04d-%02d-%02dT%02d:%02d:%02d%+03d:%02d\n",
year, month, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, tz_hour, tz_min);