-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Format Time#inspect with Internet Extended Date/Time Format
#16039
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
Format Time#inspect with Internet Extended Date/Time Format
#16039
Conversation
ysbaddaden
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have support for parsing the format?
|
Not yet. But that's the follow-up. |
| it "#inspect" do | ||
| Time.utc(2014, 1, 2, 3, 4, 5).inspect.should eq "2014-01-02 03:04:05.0 UTC" | ||
| Time.utc(2014, 1, 2, 3, 4, 5, nanosecond: 123_456_789).inspect.should eq "2014-01-02 03:04:05.123456789 UTC" | ||
| Time.utc(2014, 1, 2, 3, 4, 5).inspect.should eq "2014-01-02 03:04:05Z" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thought: Dropping the second fractions entirely when nanoseconds are zero might be debatable. I think it's more readable that way.
But that makes it ambiguous whether nanoseconds were entirely cut off (with_nanoseconds: false) or are just omitted because the subsection fraction is zero. Shortening the fraction to just .0 was more explicit. But I don't think it's that important.
with_nanoseconds: false is a rather odd feature. I'm not aware of any actual use case. It was introduced in #5794 but I don't recall what was the reason for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably deprecate with_nanoseconds.
|
Sorry for the continued editing but I realized that essential parts were missing (documentation) and the exact format could use some polishing for better readability. I have now replaced the implementation with the existing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving to a RFC or ISO standard format made sense, but not using T for readability reasons makes me wonder about the change because the most readable is the current format (SP TZ > [TZ] and SP UTC > Z).
I guess the question is: is #inspect meant for humans, in which case it must be the best readable, or for machines, in which case a standard format is better.
|
Yes, Anyways, using a space instead of |
Co-authored-by: Julien Portalier <[email protected]>
The Internet Extended Date/Time Format (IXDTF) as described in RFC 9557 is a standard for representing a timestamp together with zone information.
Changes to the format:
UTClocation byZoffsetwith_nanosecondsis true (see FormatTime#inspectwith Internet Extended Date/Time Format #16039 (comment))Resolves #15810