> However given ordinal days of the year do exist for all calendars (that I’m aware of since they all have the concept of a day) perhaps adding a callback to `Calendar` of something like `month_and_day_from_ordinal(year, ordinal)` would be something to consider? Then of course implement that for `Calendar.ISO`.
If you look at some of the discussion on my PR <https://github.com/elixir-lang/elixir/pull/10687>, you can see me wondering that exact thing. It adds `calendar_day_of_year(year, ordinal_day)` and `days_in_year(year)` as private functions to just the `Calendar.ISO`. module, but I suspect they are extrapolatable to any calendar, since they can be computed from the `days_in_month` and `months_in_year` already required by the protocol. On Thursday, February 4, 2021 at 2:24:23 PM UTC-8 Kip wrote: > > Ordinal dates are interesting because while they are not calendar > dates, they are trivially convertible into them. > > True for the proleptic Gregorian calendar, not necessarily so for other > calendars. Since ISO8601 is explicitly only concerned with that calendar I > expect this isn’t an issue. > > However given ordinal days of the year do exist for all calendars (that > I’m aware of since they all have the concept of a day) perhaps adding a > callback to `Calendar` of something like `month_and_day_from_ordinal(year, > ordinal)` would be something to consider? Then of course implement that for > `Calendar.ISO`. > > > > On 5 Feb 2021, at 6:16 am, Christopher Keele <christ...@gmail.com> wrote: > > Ordinal dates are interesting because while they are not calendar dates, > they are trivially convertible into them. > > > -- You received this message because you are subscribed to the Google Groups "elixir-lang-core" group. To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/fa9aeb27-3c8c-4b3d-88a5-1f3378b781e3n%40googlegroups.com.