Skip to content

Stricter time format constraints #481

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 23, 2021

Conversation

kylef
Copy link
Contributor

@kylef kylef commented Apr 22, 2021

Based on RFC3339's ABNF, I think this should cover all possibilities:

   time-hour       = 2DIGIT  ; 00-23
   time-minute     = 2DIGIT  ; 00-59
   time-second     = 2DIGIT  ; 00-58, 00-59, 00-60 based on leap second
                             ; rules
   time-secfrac    = "." 1*DIGIT
   time-numoffset  = ("+" / "-") time-hour ":" time-minute
   time-offset     = "Z" / time-numoffset

   partial-time    = time-hour ":" time-minute ":" time-second
                     [time-secfrac]
   full-time       = partial-time time-offset

/c @jnewc

@kylef kylef changed the title Stronger time format constraints Stricter time format constraints Apr 22, 2021
Copy link
Member

@karenetheridge karenetheridge left a comment

Choose a reason for hiding this comment

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

(edit.. that was a mispaste of something else)

We are failing on `Z+` not the invalid minute, so let's make sure that
implementors are catching that case not the (mis-copy of 00:60).
@karenetheridge
Copy link
Member

I'll leave this open for a bit to give others a chance to weigh in, but this is really good, and you found some bugs in my implementation because I was being sloppy, so 🎉 👯 ❤️

@karenetheridge karenetheridge requested a review from a team April 23, 2021 16:53
@karenetheridge karenetheridge merged commit 09fd353 into json-schema-org:master Apr 23, 2021
@kylef kylef deleted the kylef/time branch April 23, 2021 22:39
@Julian
Copy link
Member

Julian commented Apr 27, 2021

Can someone elaborate a bit on the leap second thinking?

I'm no RFC 3339 expert, but why is the leap second test valid?

Whether a leap second is allowed depends on the leap second rules in the RFC yes? Which means knowing what day it is? What interpretation makes us say including one is always a valid instance?

@karenetheridge
Copy link
Member

Without the date, all we can verify is that leap seconds can only occur just before midnight (UTC/Zulu). Technically any date in the future could have a leap second in it, since leap seconds are often only announced just before they happen. But without any date at all, all we know is this could describe a real point in time, therefore it's not invalid.

davishmcclurg added a commit to davishmcclurg/json_schemer that referenced this pull request Oct 21, 2021
Exposed by: json-schema-org/JSON-Schema-Test-Suite#481

Ruby incorrectly allows `24` as the hour in an RFC3339 timestamp.
It also does not handle leap seconds very well:

```
-> Time.parse("23:59:60Z")
=> 2021-10-18 00:00:00 UTC
```

They should only be allowed at 23:59 UTC.
davishmcclurg added a commit to davishmcclurg/json_schemer that referenced this pull request Apr 22, 2022
Exposed by: json-schema-org/JSON-Schema-Test-Suite#481

Ruby incorrectly allows `24` as the hour in an RFC3339 timestamp.
It also does not handle leap seconds very well:

```
-> Time.parse("23:59:60Z")
=> 2021-10-18 00:00:00 UTC
```

They should only be allowed at 23:59 UTC.
davishmcclurg added a commit to davishmcclurg/json_schemer that referenced this pull request May 15, 2023
Exposed by: json-schema-org/JSON-Schema-Test-Suite#481

Ruby incorrectly allows `24` as the hour in an RFC3339 timestamp.
It also does not handle leap seconds very well:

```
-> Time.parse("23:59:60Z")
=> 2021-10-18 00:00:00 UTC
```

They should only be allowed at 23:59 UTC.
davishmcclurg added a commit to davishmcclurg/json_schemer that referenced this pull request May 16, 2023
Exposed by: json-schema-org/JSON-Schema-Test-Suite#481

Ruby incorrectly allows `24` as the hour in an RFC3339 timestamp.
It also does not handle leap seconds very well:

```
-> Time.parse("23:59:60Z")
=> 2021-10-18 00:00:00 UTC
```

They should only be allowed at 23:59 UTC.
davishmcclurg added a commit to davishmcclurg/json_schemer that referenced this pull request May 22, 2023
Exposed by: json-schema-org/JSON-Schema-Test-Suite#481

Ruby incorrectly allows `24` as the hour in an RFC3339 timestamp.
It also does not handle leap seconds very well:

```
-> Time.parse("23:59:60Z")
=> 2021-10-18 00:00:00 UTC
```

They should only be allowed at 23:59 UTC.
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