mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-22 04:50:07 +00:00
cccc95f28a
Topic: strptime supports a %z input field descriptor, which parses a time zone offset from UTC time into the broken-out time field tm_gmtoff. Problems: 1) In the current implementation, the minutes portion calculation is correct only for minutes evenly divisible by 3. This is because the minutes value is converted to decimal time, but inadequate precision leads to rounding which calculates results that are too low for some values. For example, due to rounding, a +1159 offset string results in an incorrect tm_gmtoff of 43128 (== 11 * 3600 + 58.8 * 60) seconds, instead of 43140 (== 11 * 3600 + 59 * 60) seconds. In contrast, a +1157 offset (minutes divisible by 3) does not cause the bug, and results in a correct tm_gmtoff of 43020. 2) strptime's %z specifier will not parse time offsets less than -1200 or greater than +1200, or if only hour digits are present, less than -12 or greater than +12. It will return NULL for offsets outside that range. These limits do not meet historical and modern 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 3) tst-strptime2, part of the 'make check' test suite, does not test for the above problems. Corrective actions: 1) In time/strptime_l.c, calculate the offset from the hour and minute portions directly, without the rounding errors introduced by decimal time. 2) Remove the +/-1200 range limit, permitting strptime to parse offsets from -9959 through +9959. 3) Add zone offset values to time/tst-strptime2.c. * Test minutes evenly divisible by three (+1157) and not evenly divisible by three (+1158 and +1159). * Test offsets near the old and new range limits (-1201, -1330, -2459, -2500, -99, -9959, +1201, +1330, +1400, +1401, +2559, +2600, +99, and +9959) The revised strptime passes all old and new tst-strptime2 tests. |
||
---|---|---|
.. | ||
sys | ||
adjtime.c | ||
alt_digit.c | ||
asctime.c | ||
bug-asctime_r.c | ||
bug-asctime.c | ||
bug-getdate1.c | ||
bug-mktime1.c | ||
clock.c | ||
clocktest.c | ||
ctime_r.c | ||
ctime.c | ||
datemsk | ||
Depend | ||
difftime.c | ||
dysize.c | ||
era.c | ||
ftime.c | ||
getdate.c | ||
getitimer.c | ||
gettimeofday.c | ||
gmtime.c | ||
lc-time-cleanup.c | ||
localtime.c | ||
Makefile | ||
mktime.c | ||
offtime.c | ||
setitimer.c | ||
settimeofday.c | ||
stime.c | ||
strftime_l.c | ||
strftime.c | ||
strptime_l.c | ||
strptime.c | ||
test_time.c | ||
time.c | ||
time.h | ||
timegm.c | ||
timespec_get.c | ||
tst_wcsftime.c | ||
tst-ftime_l.c | ||
tst-ftime.c | ||
tst-getdate.c | ||
tst-mktime2.c | ||
tst-mktime3.c | ||
tst-mktime.c | ||
tst-posixtz.c | ||
tst-strftime.c | ||
tst-strptime2.c | ||
tst-strptime3.c | ||
tst-strptime-whitespace.c | ||
tst-strptime.c | ||
tzfile.c | ||
tzset.c | ||
Versions | ||
wcsftime_l.c | ||
wcsftime.c |