Open kipcole9 opened 4 years ago
Duration.from_iso8601/1
and Duration.to_iso8601/1
were implemented in Elixir 1.17. Implementing it is no longer needed it seems,
How do you think we could update Cldr.Calendar.Duration
to make use of the new Duration
module? Types have some differences:
Duration.t
accepts negative valuesDuration.t
has a week componentDuration.t
microsecond has a precision componentSome ideas:
Cldr.Calendar.Duration.t
and Duration.t
as parameters of to_string/2
Cldr.Calendar.Duration.from_duration
In both case, we need to handle negative duration, by rejecting them for instance.
Thank you for the thoughtful ideas @tanguilp. My current thinking is the prioritise implementing the new Elixir 1.17 Calendar callbacks. This requires more work that it might initially seem given that years may have a variable number of months and months have a variable number of days (you know this already of course).
I aim to have an initial version implemented this weekend for some exposure and testing.
Then I plan to deprecate the Cldr Durations but keep supporting them until Elixir 1.17 is the minimum supported version - that will be quite some time since I’m only now making Elixir 1.12 the minimum version. Perhaps I should be more aggressive in moving up the minimum support line.
ISO8601 defines a duration format. Add
to_iso8601
to convertCldr.Calendar.Duration.t
to this format. Andfrom_iso8601/1
to do the reverse.For now a
Cldr.Calendar.Duration/1
does not support: