Add ISO-8601 style Duration parsing
It would be convenient for users and for writing unit tests if we could parse ISO-8601 duration strings into DateDuration.
Examples:
-
P1D=>{ days: 1 } -
P2M1D=>{ months: 2, days: 1 } -
P77Y=>{ years: 77 }
@sffc i can work on this issue
Thanks! You can learn more about the duration syntax here:
https://en.wikipedia.org/wiki/ISO_8601#Durations
https://tc39.es/proposal-temporal/#prod-TemporalDurationString
Since DateDuration supports only years, months, weeks, and days, we should parse only the date fields from duration strings, and reject duration strings that have time portions after the T. So, for example, we should parse P5M but not PT5M.
This should be exported as a function DateDuration::try_from_str and DateDuration::try_from_utf8 with a corresponding FromStr impl. You can see lots of other examples of signatures of parsing functions throughout ICU4X.
can you assign me this @sffc
is this issue fixed? if not i can work on this.
No need to ask to be assigned. We don't assign backlog issues. Just create a PR linked to this issue.
Alright. Will make a pr soon
@SATVIKsynopsis your other PR #7315 is still draft and not passing tests. I suggest you focus on fixing and landing that one first.
Got it thanks for the clarification. I will focus on fixing and landing #7315 first.