-
Notifications
You must be signed in to change notification settings - Fork 555
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
[Feature Request] Support parsing ISO 8601 Duration strings #579
Comments
I was poking around the code base. I can do parsing using Parsed using similar approach as implementation of Look forward to feedback. |
I think implementing |
Is anyone working on this? I kind of need it. |
I have a use case for this. I'm thinking we might add a type like this: struct CalendarPeriod {
years: u32,
months: Months,
days: Days,
time: core::time::Duration,
} With a serde implementation. @esheppa what do you think? |
I like the struct you suggest, but this part from wiki concerns me:
A pragmatic option may be that we only support integer values everywhere but in the seconds part, however it would be interesting to understand whether that is overly restrictive. |
Oh, good catch. I can't think of any strategy for figuring out how restrictive that would be. Starting with integer values only seems like a decent approach to get at least some support in. |
ISO 8601 has a lot of features that aren't particularly useful. Personally I rather would look into supporting RFC 3339 for durations, which is a practical subset of it. In particular, its duration parts are integers only. |
Huh, Wikipedia has this:
So it looks like RFC 3339 does in fact include durations? I'm happy to bill our support as only for the RFC 3339 subset of durations. It does look like I missed a |
Nevermind, it doesn't provide durations, I just got confused by CTRL+F in RFC 3339 providing a result in "ISO 8601 Collected ABNF" section with a grammar that doesn't support decimal durations, however it is "informational only". |
However, it seems hopeful that the informational RFC 3339 grammar for duration doesn't allow decimals at all. |
We could call the support "RFC 3339 inspired" :D |
Yeah some support for something like that would be great. I'm currently trying to use chrono for ics file parsing and being able to parse the duration in these files (the duration have a format like so Having something like the |
@Ownezx would you be interested in working on a PR along the lines of the discussion above? |
I'd have to look at the source for Can't give any garantee but I can give it a try for sure. |
Just to make things clear, you'd want me to play with the |
It would be a new type, somewhat like the |
Note that JSON Schema explicitly uses ISO 8601 format durations. Since |
The crate supports parsing of date strings but, there is no equivalent support for parsing duration strings. This is request to support parsing of duration strings.
Description here -> https://en.wikipedia.org/wiki/ISO_8601#Durations.
RFC Spec - https://datatracker.ietf.org/doc/html/rfc3339#appendix-A
I am open to work on this issue but, would need direction/guidance to do the same.
The text was updated successfully, but these errors were encountered: