[v3,4/4,BZ,#16141] strptime: extend %z range to +/-9959
Commit Message
This is part of a fix for [BZ #16141] strptime %z offset restriction.
Remove limits on the strptime %z timezone range, allowing strptime to
parse time zone offsets from -9959 through +9959.
strptime supports a %z input field descriptor, which parses a time zone
offset from UTC time into the broken-out time field tm_gmtoff. The
current implementation limits the range of valid offsets to the range
-1200 to +1200, or if only the hour digits are present, -12 to +12.
NULL is returned for offsets outside that range.
However, the limits are too small for the following use cases:
* Present day exceeds the +1200 limit:
- Pacific/Auckland (New Zealand) summer time is +1300.
- Pacific/Kiritimati (Christmas Island) is +1400.
- Pacific/Apia (Samoa) summer time is +1400.
* Historical offsets exceeded +1500/-1500.
* POSIX supports -2459 to +2559.
* Offsets up to +/-9959 may occasionally be useful.
* Paul Eggert's notes provide additional detail:
- https://sourceware.org/ml/libc-alpha/2014-12/msg00068.html
- https://sourceware.org/ml/libc-alpha/2014-12/msg00072.html
When 'make check' is run on glibc, tst-strptime2 will report the error
with the output:
round 13: strptime unexpectedly failed
round 14: strptime unexpectedly failed
round 15: strptime unexpectedly failed
round 16: strptime unexpectedly failed
round 17: strptime unexpectedly failed
round 18: strptime unexpectedly failed
round 19: strptime unexpectedly failed
round 20: strptime unexpectedly failed
round 21: strptime unexpectedly failed
round 22: strptime unexpectedly failed
round 23: strptime unexpectedly failed
round 24: strptime unexpectedly failed
round 25: strptime unexpectedly failed
round 26: strptime unexpectedly failed
The fix removes the +/-1200 range limit, permitting strptime to parse
offsets from -9959 through +9959. The tst-strptime2 test will then
succeed.
James
2014-12-03 James Perkins james@loowit.net
[BZ #16141]
* time/strptime_l.c (__strptime_internal): Extend %z time zone
offset range limits to UTC-99:59 through UTC+99:59 to parse
current and historical use cases.
---
time/strptime_l.c | 2 --
1 file changed, 2 deletions(-)
@@ -773,8 +773,6 @@ __strptime_internal (rp, fmt, tmp, statep LOCALE_PARAM)
else if (val % 100 >= 60)
/* Minutes valid range is 0 through 59. */
return NULL;
- if (val > 1200)
- return NULL;
tm->tm_gmtoff = (val / 100) * 3600 + (val % 100) * 60;
if (neg)
tm->tm_gmtoff = -tm->tm_gmtoff;