summaryrefslogtreecommitdiff
path: root/src/time/__tz.c
AgeCommit message (Collapse)AuthorLines
2013-08-24properly fill in tzname[] for old (pre-64-bit-format) zoneinfo filesRich Felker-1/+22
in this case, the first standard-time and first daylight-time rules should be taken as the "default" ones to expose.
2013-08-24minor fix to tz name checkingRich Felker-2/+2
if a zoneinfo file is not (or is no longer) in use, don't check the abbrevs pointers, which may be invalid.
2013-08-24fix strftime handling of time zone dataRich Felker-3/+17
this may need further revision in the future, since POSIX is rather unclear on the requirements, and is designed around the assumption of POSIX TZ specifiers which are not sufficiently powerful to represent real-world timezones (this is why zoneinfo support was added). the basic issue is that strftime gets the string and numeric offset for the timezone from the extra fields in struct tm, which are initialized when calling localtime/gmtime/etc. however, a conforming application might have created its own struct tm without initializing these fields, in which case using __tm_zone (a pointer) could crash. other zoneinfo-based implementations simply check for a null pointer, but otherwise can still crash of the field contains junk. simply ignoring __tm_zone and using tzname[] would "work" but would give incorrect results in time zones with more complex rules. I feel like this would lower the quality of implementation. instead, simply validate __tm_zone: unless it points to one of the zone name strings managed by the timezone system, assume it's invalid. this commit also fixes several other minor bugs with formatting: tm_isdst being negative is required to suppress printing of the zone formats, and %z was using the wrong format specifiers since the type of val was changed, resulting in bogus output.
2013-08-23fix mishandling of empty or blank TZ environment variableRich Felker-1/+1
the empty TZ string was matching equal to the initial value of the cached TZ name, thus causing do_tzset never to run and never to initialize the time zone data.
2013-07-17the big time handling overhaulRich Felker-0/+389
this commit has two major user-visible parts: zoneinfo-format time zones are now supported, and overflow handling is intended to be complete in the sense that all functions return a correct result if and only if the result fits in the destination type, and otherwise return an error. also, some noticable bugs in the way DST detection and normalization worked have been fixed, and performance may be better than before, but it has not been tested.