From 0748546f660d27a2ad29fa6174d456e2f6490758 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 18 Sep 2013 13:15:12 -0700 Subject: Support TZ transition times < 00:00:00. This is needed for version-3 tz-format files; it supports time stamps past 2037 for America/Godthab (the only entry in the tz database for which this change is relevant). * manual/time.texi (TZ Variable): Document transition times from -167:59:59 through -00:00:01. * time/tzset.c (tz_rule): Time of day is now signed. (__tzset_parse_tz): Parse negative time of day. --- time/tzset.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'time') diff --git a/time/tzset.c b/time/tzset.c index 4f8af8d..fb2dccd 100644 --- a/time/tzset.c +++ b/time/tzset.c @@ -54,7 +54,7 @@ typedef struct /* When to change. */ enum { J0, J1, M } type; /* Interpretation of: */ unsigned short int m, n, d; /* Month, week, day. */ - unsigned int secs; /* Time of day. */ + int secs; /* Time of day. */ long int offset; /* Seconds east of GMT (west if < 0). */ @@ -362,9 +362,12 @@ __tzset_parse_tz (tz) else if (*tz == '/') { /* Get the time of day of the change. */ + int negative; ++tz; if (*tz == '\0') goto out; + negative = *tz == '-'; + tz += negative; consumed = 0; switch (sscanf (tz, "%hu%n:%hu%n:%hu%n", &hh, &consumed, &mm, &consumed, &ss, &consumed)) @@ -379,7 +382,7 @@ __tzset_parse_tz (tz) break; } tz += consumed; - tzr->secs = (hh * 60 * 60) + (mm * 60) + ss; + tzr->secs = (negative ? -1 : 1) * ((hh * 60 * 60) + (mm * 60) + ss); } else /* Default to 2:00 AM. */ -- cgit v1.1