Skip to content

use the TZ string footer of zoneinfo files after the last transition - #944

Merged
HowardHinnant merged 1 commit into
HowardHinnant:masterfrom
emincan2000:os-tzdb-posix-footer
Oct 29, 2026
Merged

HowardHinnant merged 1 commit into
HowardHinnant:masterfrom
emincan2000:os-tzdb-posix-footer

Conversation

@emincan2000

Copy link
Copy Markdown
Contributor

With USE_OS_TZDB the TZ string at the end of the zoneinfo files is ignored, so after the last explicit transition the zone just keeps its last offset forever. On a normal fat install that means no DST after 2037 (New York in July 2040 comes out as EST), and on slim installs it goes wrong a lot earlier. This reads the footer when the zone is loaded and hands anything past the last transition to Posix::time_zone from ptz.h, since that already parses these strings. Times before the last transition still go through the table like before.

Fixes #794 and #874.

Tested on Arch (tzdata 2026e) by checking get_info for both sys and local times against Python zoneinfo for every zone, hourly around 2037 to 2039 plus random times up to year 2500, about 3.5M checks with 0 diffs. Master gets roughly 5% of random times wrong. Built with gcc 16 and clang 23 in C++11 through C++23 with no new warnings, and the ctest run is the same as master (validate aborts on both at the same non TZif file). FWIW lookups past the last transition take ~70ns instead of ~10ns since the string gets parsed per call, earlier times are unchanged.

One small difference: for those future times save is the real value from the rule (60min) instead of the 1min flag the table path uses.

With USE_OS_TZDB the TZif footer was ignored, so any time after the last
explicit transition kept the last offset forever. With fat files that
means no DST after 2037, and with slim files it starts much earlier.
Read the footer and hand those times to Posix::time_zone from ptz.h.

Fixes HowardHinnant#794
Fixes HowardHinnant#874
@HowardHinnant
HowardHinnant merged commit d709492 into HowardHinnant:master Oct 29, 2026
@HowardHinnant

Copy link
Copy Markdown
Owner

This is awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"TZ string" is ignored when loading times zones from tzfiles

2 participants