elixir-cldr / cldr_dates_times

Date & times formatting functions for the Common Locale Data Repository (CLDR) package https://github.com/elixir-cldr/cldr
Other
69 stars 13 forks source link

Issue with Cldr.Date.to_string! failing in Cldr.Calendar.Gregorian #17

Closed LostKobrakai closed 4 years ago

LostKobrakai commented 4 years ago

The following line doesn't work for me: Cldr.Date.to_string!(hour.day, format: "EE")

 ** (UndefinedFunctionError) function Cldr.Calendar.Gregorian.day_of_week/4 is undefined or private
        (ex_cldr_calendars 1.9.0) Cldr.Calendar.Gregorian.day_of_week(2020, 7, 2, :default)
        (elixir 1.11.0-dev) lib/calendar/date.ex:718: Date.day_of_week/2
        (ex_cldr_calendars 1.9.0) lib/cldr/calendar.ex:1899: Cldr.Calendar.localize/6
        (elixir 1.11.0-dev) lib/enum.ex:1399: Enum."-map/2-lists^map/1-0-"/2
        (connect 0.8.0) lib/cldr/backend/formatter.ex:115: Connect.Cldr.Backend.DateTime.Formatter.format/4
        (ex_cldr_dates_times 2.5.1) lib/cldr/date.ex:105: Cldr.Date.to_string/3
        (ex_cldr_dates_times 2.5.1) lib/cldr/date.ex:191: Cldr.Date.to_string!/3
        (connect 0.8.0) lib/connect_web/templates/app/manage/activity_information/show.html.eex:46: anonymous fn/1 in ConnectWeb.App.Manage.ActivityInformationView."show.html"/1
LostKobrakai commented 4 years ago

Ok, just confirmed my hunch. Breaks because of elixir 1.11

kipcole9 commented 4 years ago

Elixir 1.11 support remains open because of the ambiguity of what day_of_week/2/4 returns. It has always been ambiguous but consistent since the start of week was always Monday. This means that until now, Elixir and Cldr always returned the same result and the result was the same whether you interpret the day of week as ordinal or cardinal.

Now Elixir definitely returns the ordinal day of week. Most of CLDR assumes that the day of week is cardinal.

José believes this is an individual calendar decision to make. While I don't agree, I need to deal with reality and somehow navigate this without breaking backwards compatibility and still remain compatible with Calendar.ISO behaviour. Especially since Cldr.Calendar.Gregorian is - by design - intentionally meant to deliver a compatible experience.

It is possible I will only support only the :default option for Cldr.Calendar to start with since that will ensure the compatibility required but I'm not happy about this limitation either.

kipcole9 commented 4 years ago

I have updated ex_cldr_calendars to version 1.10.0 which adds support for Elixir 1.11. I have run tests on ex_cldr_dates_times on Elixir master so I think you should now be good to go if you mix deps.update ex_cldr_calendars ex_cldr.

Of course let me know if the issue is not solved ....