/* Use time zone TZ to compute mktime (TM). */ time_t mktime_z (timezone_t tz, struct tm *tm) { if (!tz) return timegm (tm); else { timezone_t old_tz = set_tz (tz); if (old_tz) { time_t t = mktime (tm); #if HAVE_TM_ZONE || HAVE_TZNAME time_t badtime = -1; struct tm tm_1; if ((t != badtime || (localtime_r (&t, &tm_1) && equal_tm (tm, &tm_1))) && !save_abbr (tz, tm)) t = badtime; #endif if (revert_tz (old_tz)) return t; } return -1; } }
/* Use time zone TZ to compute localtime_r (T, TM). */ struct tm * localtime_rz (timezone_t tz, time_t const *t, struct tm *tm) { if (!tz) return gmtime_r (t, tm); else { timezone_t old_tz = set_tz (tz); if (old_tz) { bool abbr_saved = localtime_r (t, tm) && save_abbr (tz, tm); if (revert_tz (old_tz) && abbr_saved) return tm; } return NULL; } }
/* Use time zone TZ to compute localtime_r (T, TM). */ struct tm * localtime_rz (timezone_t tz, time_t const *t, struct tm *tm) { if (!tz) return gmtime_r (t, tm); else { timezone_t old_tz = set_tz (tz); if (old_tz) { tm = localtime_r (t, tm); if (tm && !save_abbr (tz, tm)) tm = NULL; if (revert_tz (old_tz)) return tm; } return NULL; } }