Accept second value 60 for leap seconds in times and datetimes - #46
Open
LordAizen1 wants to merge 1 commit into
Open
Accept second value 60 for leap seconds in times and datetimes#46LordAizen1 wants to merge 1 commit into
LordAizen1 wants to merge 1 commit into
Conversation
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.
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.
tomlc17 rejects
23:59:60, but RFC 3339 allows second 60 for leap seconds. The ABNF saystime-second = 2DIGIT ; 00-58, 00-59, 00-60 based on leap second rules, and1990-12-31T23:59:60Zis one of its own examples.is_valid_timecaps seconds at 59, so these fail as "invalid time".toml-test agrees
:60is valid: its over-the-limit case uses:61and quotes that same ABNF line, and there's no valid:60fixture, which is why nothing caught this.:61is 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 thetest/parserdatetime fixture.Heads up: this accepts
:60at 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.