-
-
Notifications
You must be signed in to change notification settings - Fork 278
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
Well-known format descriptions should support formatting Date. #616
Comments
For RFC 2822 and RFC 3339, the only supported formats are all-inclusive, as there is no indication in the specifications that anything else is permitted. For ISO 8601, this can absolutely be done with the addition of an associated const.
Completely unrelated, but do not rely on
The config can be inlined; a separately declared const isn't strictly necessary.
The implementation has no knowledge of what type is actually being formatted. The default configuration for ISO 8601 is documented as formatting the date, time, and UTC offset.
This is almost certainly what will be done. It'll be quite easy to add further associated constants. |
Agreed, for 2822 it probably doesn't make sense, you never see those with the time omitted either. However I don't read RFC 3339 as requiring there be a time, and I do see date-only RFC-3339 in use. For example, GNU Coreutils' date lets you do The RFC's ABNF breaks it out separately as
But it doesn't positively say the time is optional either, and the examples all have both date and time. Ultimately, being a subset of ISO 8601, as long as that code can do it easily, it doesn't matter :) An associated const on
You're right, I was getting a syntax error when I tried earlier, but I took another look and figured out what I was doing wrong. The syntax for it is very unusual (I don't think I've seen it before in my ~7 years of doing rust 😄). You have to use braces around the const expression:
|
I have implemented more associated constants for With regard to RFC 2822 and RFC 3339, I see no indication in either that there is intent to permit date-only formatting, among others. In neither RFC does the ABNF clearly show that each item is to be permitted on its own. Such an interpretation would be seem to also permit formatting only the hours, for example, which is presumably not the goal. I also checked the ABNF specification to see if there was anything implicit that I wasn't aware of, but did not find anything. For the
RFC 3339 may have been a subset of ISO 8601 when it was written, but it's not a subset of the latest version of ISO 8601 (from 2019). There are minor differences here and there. As I've implemented the associated constants for ISO 8601 and don't see where it's permitted in the two RFCs, I'm closing this as completed. Thank you for the request! |
This is great, thanks! |
None of the three well-known format descriptions provided here support formatting
Date
instances:Far as I can tell, the only way to format a date without using
parse()
to construct my own format is to do this very long-winded incantation:And this has to have the config declared as a const and can't be written as a one-liner. This is extremely verbose for such a basic operation.
Can I request either one of these changes:
The text was updated successfully, but these errors were encountered: