elixir-cldr / cldr_calendars

Calendar functions for CLDR
Other
15 stars 6 forks source link

Add to_iso8601/1 for duration #7

Open kipcole9 opened 4 years ago

kipcole9 commented 4 years ago

ISO8601 defines a duration format. Add to_iso8601 to convert Cldr.Calendar.Duration.t to this format. And from_iso8601/1 to do the reverse.

For now a Cldr.Calendar.Duration/1 does not support:

  1. Week durations
  2. Negative durations
  3. Durations where the date/time components are unordered
tanguilp commented 2 months 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:

Some ideas:

In both case, we need to handle negative duration, by rejecting them for instance.

kipcole9 commented 2 months ago

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.