-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
to_rfc3339
can generate invalid RFC 3339 timestamps
#7
Comments
This is fine, but we can document that timestamps outside the specified range can be generated. |
Here is another example of generating invalid RFC 3339 timestamps. This time it is with a timestamp that is in the normal range. Test function pub fn to_rfc3339_9_test() {
timestamp.from_unix_seconds(-62_167_219_200)
|> timestamp.to_rfc3339(0)
|> should.equal("0000-01-01T00:00:00Z")
} Test result:
The previous examples I can understand being okay, since the timestamp is outside of the natural domain of the RFC 3339 formatted timestamps, but this example seems to be a bug: the timestamp is in the accepted range, but the format is off. The cause is here: time/src/gleam/time/timestamp.gleam Line 173 in 91c9739
And here: time/src/gleam/time/timestamp.gleam Line 175 in 91c9739
(This example with the two digit year does appear to conform to the ISO 8601 grammar given in the RFC 3339 appendix, but not to the RFC 3339 grammar.) |
Oops, that's a copy paste fail for me. I remember intending to pad to 4 😄 |
The
to_rfc3339
can generate invalid RFC 3339 timestamps. For example:From the RFC 3339:
Also the grammar doesn't allow for years with more than 4 digits (or negative years).
I'm not really sure what the "correct" behavior here should be (maybe clamping? maybe return a
Result(String, _)
?)The text was updated successfully, but these errors were encountered: