Skip to content

Accept second value 60 for leap seconds in times and datetimes - #46

Open
LordAizen1 wants to merge 1 commit into
cktan:mainfrom
LordAizen1:leap-second-60
Open

Accept second value 60 for leap seconds in times and datetimes#46
LordAizen1 wants to merge 1 commit into
cktan:mainfrom
LordAizen1:leap-second-60

Conversation

@LordAizen1

@LordAizen1 LordAizen1 commented Jul 25, 2026

Copy link
Copy Markdown

tomlc17 rejects 23:59:60, but RFC 3339 allows second 60 for leap seconds. The ABNF says time-second = 2DIGIT ; 00-58, 00-59, 00-60 based on leap second rules, and 1990-12-31T23:59:60Z is one of its own examples. is_valid_time caps seconds at 59, so these fail as "invalid time".

toml-test agrees :60 is valid: its over-the-limit case uses :61 and quotes that same ABNF line, and there's no valid :60 fixture, which is why nothing caught this. :61 is still rejected after the change, so the existing toml-test cases don't move.

Fix is one character (sec <= 60). Adds leap-second cases to the test/parser datetime fixture.

Heads up: this accepts :60 at any position (e.g. 00:00:60), not only at true leap-second instants, same as the reference RFC 3339 parsers, since a parser can't carry the leap-second table.

RFC 3339 allows a second value of 60 for leap seconds. Its ABNF is explicit
(time-second = 2DIGIT ; 00-58, 00-59, 00-60 based on leap second rules) and it
uses 1990-12-31T23:59:60Z as a worked example. TOML date-times are RFC 3339
date-times, so these should parse, but is_valid_time capped seconds at 59 and
rejected them as "invalid time".

toml-test already treats :60 as valid: its over-the-limit case uses :61 and
quotes that same ABNF line. There is no valid :60 fixture in the suite, which
is why this went uncaught. :61 is still rejected after this change, so the
existing toml-test cases are unaffected.

Adds leap1/leap2 cases to the test/parser datetime fixture.
Copilot AI review requested due to automatic review settings July 25, 2026 05:45

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

2 participants