summaryrefslogtreecommitdiffstats
path: root/newlib/libc/time/mktime.c
diff options
context:
space:
mode:
Diffstat (limited to 'newlib/libc/time/mktime.c')
-rw-r--r--newlib/libc/time/mktime.c17
1 files changed, 9 insertions, 8 deletions
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;