Allow building on platforms without `struct tm.tm_gmtoff`, `timezone`, `daylight`
I'm not happy about this because the results are non-intuitive, but that
looks like something which originates in libyang's attempts to use local
TZ everywhere instead of normalizing to UTC time.
But hey, this only matters on a platform which cannot "easily" represent
timezones in `struct tm`, or for which we cannot determine the TZ/DST
status without going the extra mile of writing non-POSIX stuff. So as
long as we mark the returned value with "I cannot really vouch for the
TZ", this *might* even be standard-compliant.
diff --git a/src/tree_data_helpers.c b/src/tree_data_helpers.c
index 714b1fd..94b5fd1 100644
--- a/src/tree_data_helpers.c
+++ b/src/tree_data_helpers.c
@@ -934,6 +934,7 @@
return LY_ESYS;
}
+#ifdef HAVE_TM_GMTOFF
/* get timezone offset */
if (tm.tm_gmtoff == 0) {
/* time is Zulu (UTC) */
@@ -945,6 +946,11 @@
zonediff_m = tm.tm_gmtoff / 60 % 60;
}
sprintf(zoneshift, "%+03d:%02d", zonediff_h, zonediff_m);
+#else
+ (void)zonediff_h;
+ (void)zonediff_m;
+ sprintf(zoneshift, "-00:00");
+#endif
/* print */
if (asprintf(str, "%04d-%02d-%02dT%02d:%02d:%02d%s%s%s",