#include <h/tws.h>
#include <time.h>
+#if !defined(HAVE_STRUCT_TM_TM_GMTOFF)
+extern long timezone;
+#endif
+
/*
* The number of days in the year, accounting for leap years
*/
if (tm->tm_isdst)
tw.tw_flags |= TW_DST;
+#ifdef HAVE_STRUCT_TM_TM_GMTOFF
+ tw.tw_zone = tm->tm_gmtoff / 60;
+ if (tm->tm_isdst) /* if DST is in effect */
+ tw.tw_zone -= 60; /* reset to normal offset */
+#else
tzset();
tw.tw_zone = -(timezone / 60);
+#endif
tw.tw_flags &= ~TW_SDAY;
tw.tw_flags |= TW_SEXP;
/*
- * Get the timezone for given offset
+ * Get the timezone for given offset.
+ * This used to return a three-letter abbreviation for some offset
+ * values. But not many. Until there's a good way to do that,
+ * return the string representation of the numeric offset.
*/
char *
hours = offset / 60;
}
- if (!(flags & TW_ZONE) && mins == 0) {
- tzset();
- return ((flags & TW_DST) ? tzname[1] : tzname[0]);
- }
-
#ifdef ADJUST_NUMERIC_ONLY_TZ_OFFSETS_WRT_DST
if (flags & TW_DST)
hours += 1;