libstdc++: Support ON-format DAY in Zone UNTIL field [PR124852]
The libstdc++ now correctly parses complex day specifications in timezone definitions, fixing misinterpretations of historical dates.
The libstdc++‘s timezone database parser now supports extended day-of-month formats (e.g., lastSun, Sun>=8) in the UNTIL field of Zone lines. Previously, the parser only accepted plain day-of-month integers, leading to misinterpretations of dates in certain timezones like Europe/Simferopol. This commit rectifies this by implementing a more robust parser and introducing a new test case to ensure correct handling of these formats.
In Details
This commit modifies src/c++20/tzdb.cc to correctly parse the DAY field in the UNTIL line of ZoneInfo entries. The original parser only accepted integer day values, whereas the full tzdata.zi grammar allows for lastSun, Sun>=8, etc. The patch introduces on_day_t to handle these ON-style day specifications, and refactors the input stream operator accordingly. The pin() method of the on_day struct then resolves the year/month-relative day. Fixes PR124852.
For Context
The C++ standard library includes facilities for handling time zones, which are defined in a database. This database specifies when time zone rules change, such as the transition to and from daylight saving time. The timezone definitions specify an UNTIL field which defines when a given rule is valid until. The DAY field in the UNTIL section can have complex specifications like "last Sunday of the month". This commit fixes a bug where these complex day specifications were not correctly parsed, potentially leading to incorrect timezone calculations.