GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
libstdc++

libstdc++: Make chrono::parse support valid leap seconds [PR126543]

libstdc++'s chrono::parse now correctly handles and validates leap seconds, including the time '23:59:60'.

The chrono::parse function in libstdc++ has been updated to correctly parse and validate leap seconds. It now accepts ‘23:59:60’ as a valid time for UTC, provided it’s a recognized leap second. For other time types, ‘:60’ is still rejected for seconds. This change ensures that formatting UTC times to include a leap second and then parsing them back is fully supported, addressing PR126543.

In Details

This commit enhances libstdc++'s chrono::parse to correctly handle leap seconds, specifically addressing PR126543. The from_stream function is updated to use chrono::get_leap_second_info to validate if a parsed '60' in the seconds field corresponds to an actual leap second. This validation is applied only to utc_time. For other time types, ':60' is still disallowed for seconds. The changes also include updates to test cases to verify correct parsing of whole and fractional seconds, and a new test case for leap second validation.

For Context
chrono::parse
A function within the C++ standard library's chrono facilities used for parsing time-related strings into time objects.
leap second
A one-second adjustment added occasionally to Coordinated Universal Time (UTC) to keep it close to astronomical time. Leap seconds are typically inserted at the end of June or December.
UTC
Coordinated Universal Time, the primary time standard by which the world regulates clocks and time.
libstdc++
The GNU implementation of the C++ Standard Library.
PR126543
A bug report identifier within the GCC bug tracking system.
Filed Under: libstdc++chronoleap secondbugfix