Skip to content

test(format/date-time): add high-precision second fraction as valid#962

Open
vtushar06 wants to merge 1 commit into
json-schema-org:mainfrom
vtushar06:datetime-secfrac-precision
Open

test(format/date-time): add high-precision second fraction as valid#962
vtushar06 wants to merge 1 commit into
json-schema-org:mainfrom
vtushar06:datetime-secfrac-precision

Conversation

@vtushar06

Copy link
Copy Markdown
Contributor

Following the methodology I used for ipv4 and uuid, I read RFC 3339 section 5.6 and found the suite has no date-time test for a second fraction long enough to expose the float-coercion bound in a real validator.

RFC 3339 section 5.6 defines time-secfrac = "." 1*DIGIT - the fraction is unbounded, any number of digits is valid. 1985-04-12T00:59:59.999999999999999Z (second 59, fifteen 9s) is therefore valid. This exercises the boundary a validator hits if it coerces the seconds field to a float: fifteen 9s is the smallest count that rounds 59.999... up to exactly 60.0.

Changes

  • Added 1 test case across draft3, draft4, draft6, draft7, draft2019-09, draft2020-12, and v1.
  • 1985-04-12T00:59:59.999999999999999Z - a valid second fraction of fifteen 9s - valid.

Ecosystem Impact

  1. ajv-formats 3.0.1 full: FAILS (rejects it). ajv computes sec = Number("59." + fifteen 9s), which is 60.0 exactly (IEEE-754; the gap between representable doubles at 60 is 2^-47), so sec < 60 is false and it falls into the leap-second branch, which needs UTC hour 23 - at hour 00 it rejects a valid input. This is the default addFormats(ajv) mode; ajv-fast (pure regex) accepts it. Fourteen 9s (the control) stays below 60.0 and is accepted.
  2. python-jsonschema 4.25.1: PASSES (accepts it).
  3. sourcemeta/core is_rfc3339_datetime: PASSES (accepts it).
  4. Corroboration: jsonschema-rs 0.45.0, boon 0.6.1, santhosh-tekuri/jsonschema v6.0.2, and @hyperjump/json-schema 1.17.6 all accept it - ajv-formats full is the lone validator wrongly rejecting a valid input.

RFC References

Reproduction and the date-time cross-implementation matrix are in my evidence repo: https://github.com/vtushar06/JSON-Schema-format-test-Evidence/blob/main/date-time.md

Related: #965

@vtushar06 vtushar06 requested a review from a team as a code owner July 1, 2026 13:47
Copilot AI review requested due to automatic review settings July 1, 2026 13:47

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.

Pull request overview

Adds a new format: "date-time" conformance test to ensure validators accept RFC 3339 second fractions with sufficiently high precision (15 fractional digits), helping catch implementations that incorrectly coerce seconds into IEEE-754 floats and mis-handle boundary rounding.

Changes:

  • Added a valid date-time instance with a 15-digit fractional second (1985-04-12T00:59:59.999999999999999Z) to each supported test suite variant (draft3/4/6/7 optional, draft2019-09 optional, draft2020-12 optional, and v1).
  • Ensures consistent coverage across all existing tests/**/format/date-time.json files in the repository.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/v1/format/date-time.json Adds a new valid high-precision fractional-second date-time test case.
tests/draft7/optional/format/date-time.json Adds the same valid high-precision fractional-second date-time test case.
tests/draft6/optional/format/date-time.json Adds the same valid high-precision fractional-second date-time test case.
tests/draft4/optional/format/date-time.json Adds the same valid high-precision fractional-second date-time test case.
tests/draft3/optional/format/date-time.json Adds the same valid high-precision fractional-second date-time test case.
tests/draft2020-12/optional/format/date-time.json Adds the same valid high-precision fractional-second date-time test case.
tests/draft2019-09/optional/format/date-time.json Adds the same valid high-precision fractional-second date-time test case.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jviotti jviotti left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ha. Funny one!

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.

3 participants