libstdc++: Correctly cascade wall-time saves in lazy timezone expansion
Fixes timezone calculations for zones with wall-time rules by properly accounting for accumulated time savings from preceding rules.
This change corrects an issue in libstdc++‘s timezone database where wall-time saves were not being correctly cascaded when seeding system information. Previously, each rule was evaluated in isolation, ignoring the accumulated offset from prior rules in the same year. This led to incorrect timezone offsets for zones like Europe/Paris around 1945, where the interaction between rules determines the actual wall-time offset. The fix enhances the lookup algorithm to consider three rule transitions (current, previous, and next) to accurately adjust start times and determine the active rule, aligning behavior with zic and libc.
In Details
The tzdata parsing in libstdc++'s _M_get_sys_info had a flaw in determining the active rule for wall-time transitions. When seeding sys_info, it evaluated rules in isolation against ri.offset(), ignoring cascaded saves from earlier rules within the same year. This commit refactors the finding algorithm to collect three transitions around a target time t: curr_tran, prev_tran, and next_tran. It then uses these to adjust curr_tran.start_time based on prev_tran.save, and next_tran.start_time based on curr_tran.save, ensuring correct wall-time calculations, particularly fo…
- tzdb
- Time Zone Database, a collection of files specifying the timekeeping rules for many historical and political regions of the world.
- wall-time
- Local time as observed by people in a particular time zone, including adjustments for daylight saving time.
- zic
- The timezone compiler, a program that processes timezone data files into a binary format used by the operating system.
- CET
- Central European Time, a time zone observed in Europe, which is UTC+1.
- CEMT
- Central European Mean Time, an older term for CET. In the context of the commit, it appears to represent a specific offset/DST state that was incorrectly identified.
- UT
- Universal Time, a primary time standard by which the world regulates clocks and time. Often synonymous with UTC (Coordinated Universal Time).