Repository navigation
use the TZ string footer of zoneinfo files after the last transition - #944
Merged
HowardHinnant merged 1 commit intoOct 29, 2026
Merged
Conversation
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
Owner
|
This is awesome! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.