From 6b9a74f9e625e8e4d96e325b959ebead48e4a192 Mon Sep 17 00:00:00 2001 From: Jeff Johnston Date: Wed, 23 Feb 2005 19:08:58 +0000 Subject: 2005-02-23 Jeff Johnston * libc/include/time.h [!CYGWIN](_timezone): Change to long. (__tzrule_type, __tzinfo_type): New types. (__gettzinfo): New function. * libc/sys/linux/include/time.h: Ditto. * libc/time/Makefile.am: Add gettzinfo.c. * libc/time/Makefile.in: Regenerated. * libc/time/local.h: Moved __tzrule_type to time.h. * libc/time/mktime.c: Call __gettzinfo to reference __tznorth, __tzyear, and __tzrule array. * libc/time/mktm_r.c: Ditto. * libc/time/strftime.c: Ditto. * libc/time/tzset_r.c: Ditto. Also remove definition of __tzrule which is now in gettzinfo.c. Change _timezone references to not cast to time_t. * libc/time/gettzinfo.c: New file. --- newlib/libc/time/mktime.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'newlib/libc/time/mktime.c') diff --git a/newlib/libc/time/mktime.c b/newlib/libc/time/mktime.c index f6f080d84..8cd9564a9 100644 --- a/newlib/libc/time/mktime.c +++ b/newlib/libc/time/mktime.c @@ -158,6 +158,7 @@ mktime (tim_p) time_t tim = 0; long days = 0; int year, isdst; + __tzinfo_type *tz = __gettzinfo (); /* validate structure */ validate_structure (tim_p); @@ -206,19 +207,19 @@ mktime (tim_p) if (_daylight) { int y = tim_p->tm_year + YEAR_BASE; - if (y == __tzyear || __tzcalc_limits (y)) + if (y == tz->__tzyear || __tzcalc_limits (y)) { /* calculate start of dst in dst local time and start of std in both std local time and dst local time */ - time_t startdst_dst = __tzrule[0].change - __tzrule[1].offset; - time_t startstd_dst = __tzrule[1].change - __tzrule[1].offset; - time_t startstd_std = __tzrule[1].change - __tzrule[0].offset; + time_t startdst_dst = tz->__tzrule[0].change - tz->__tzrule[1].offset; + time_t startstd_dst = tz->__tzrule[1].change - tz->__tzrule[1].offset; + time_t startstd_std = tz->__tzrule[1].change - tz->__tzrule[0].offset; /* if the time is in the overlap between dst and std local times */ if (tim >= startstd_std && tim < startstd_dst) ; /* we let user decide or leave as -1 */ else { - isdst = (__tznorth + isdst = (tz->__tznorth ? (tim >= startdst_dst && tim < startstd_std) : (tim >= startdst_dst || tim < startstd_std)); /* if user committed and was wrong, perform correction */ @@ -226,7 +227,7 @@ mktime (tim_p) { /* we either subtract or add the difference between time zone offsets, depending on which way the user got it wrong */ - int diff = __tzrule[0].offset - __tzrule[1].offset; + int diff = tz->__tzrule[0].offset - tz->__tzrule[1].offset; if (!isdst) diff = -diff; tim_p->tm_sec += diff; @@ -239,9 +240,9 @@ mktime (tim_p) /* add appropriate offset to put time in gmt format */ if (isdst == 1) - tim += __tzrule[1].offset; + tim += tz->__tzrule[1].offset; else /* otherwise assume std time */ - tim += __tzrule[0].offset; + tim += tz->__tzrule[0].offset; /* reset isdst flag to what we have calculated */ tim_p->tm_isdst = isdst; -- cgit v1.2.3