-
Notifications
You must be signed in to change notification settings - Fork 16
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
Missing "T" in RFC3339 print? #185
Comments
Hi @aaronsteers , thanks for posting. RFC3339 has a "T" by default, but allows other characters—space being the most common option.
Over time, "RFC3339" has become almost synonymous with this "readable" alternative to ISO8601. For this reason, I decided to use a space character since the >>> Instant.now().format_common_iso()
'2024-11-08T20:59:45.850463Z' I've thought of adding a PS: there is one subtler difference between ISO8601 and RFC3339: ISO8601 can represent UTC offsets at second-level precision, i.e. edit: punctuation |
My aim is definitely to provide 'least surprise' and deterministic output. Taking a look at the docs of |
I don't really have a preference one way or the other, but that section of RFC 3339 is quite confusing to me. It seems to mention the space is an allowable separator right after saying that the separator should be 'T'. Section 5.5 also says that this is a subset of ISO8601, and using a space would mean it isn't ISO8601 compliant anymore... EDIT: I may have been wrong about the T being required in ISO8601, but Appendix A of RFC3339 seems to indicate that the T is required in that specification:
|
@gazpachoking 100% agree that the whole situation is unfortunate. The phrasing in RFC3339 is terrible. It even implies any character is fine! Since the RFC itself is a bit ambiguous, I decided to implement what most devs expect from RFC3339 and what most datetime libraries do (i.e. space, T, or underscore) edit: missing words |
The latest 0.6.12 release just now includes relevant improvements to the docs. |
@ariebovenberg - Thanks for the quick and thorough reply. The docs update is very welcome, thanks for that! I like your proposal to use iso option and I think that will meet my use case. When considering the output (and not the parsing requirements), the ISO 8601 output seems to also be compliant with RFC3339, but with the "T" delimiter guaranteed. What I struggle with is that ISO (as you mention) has so many variants, I worry that it is not super helpful as a promised output format that will be 100% machine readable by all consumers. For my own documentation internally, is it safe to say that for most use cases (esp those derived from Instant) that our ISO output is also compliant with the "T" variant of RFC339? |
Yes. The format
I can relate. What's frustrating is that it was RFC3339's explicit goal to reduce this variability, but I can't understand why they stopped short of doing just that. Also fun fact: they allow In the future, there will be a edit: grammar |
@ariebovenberg - Appreciate the thoughtful replies. Frustration here is admittedly more with the community and standards - not an issue with this library. As a side note, Pendulum (apparently) changed their default So as to not leave any room for accidentally using the wrong string format, I was considering subclassing Whenever's core classes to provide an explicit Closing this issue as resolved - thanks again for your help! |
I'm seeing a surprising result from
format_rfc3339()
.I thought that this would always contain a "T" to delimit the date and time part, but I'm actually seeing space as a delimiter.
The
Instant
class seems to correctly use the "T" delimiter in the implicit__str__()
operation, but callingformat_rfc3339()
gives me the space delimiter instead - which I do not want.Context: I'm hoping to move from Pendulum to whenever, and trying to ensure I have deterministic string renderings when I serialize these in a jsonified output format.
The text was updated successfully, but these errors were encountered: