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

Cldr.DateTime.Relative.to_string does not work properly with specified :unit #25

Closed DaTrader closed 3 years ago

DaTrader commented 3 years ago

This is ok:

iex(64)> MyApp.Cldr.DateTime.Relative.to_string( ~D[2021-10-01], relative_to: Date.utc_today())            
{:ok, "in 2 weeks"}

This is not:

iex(63)> MyApp.Cldr.DateTime.Relative.to_string( ~D[2021-10-01], relative_to: Date.utc_today(), unit: :day)
{:ok, "in 1,036,800 days"}

Actually, whatever unit is specified, it will always return the same number (in this case 1,036,800).

kipcole9 commented 3 years ago

Thanks for the report, apologies for the inconvenience. I have pushed commit c5f6d30 which I believe fixes the issue. Would you be able to check using {:ex_cldr_dates_times, github: "elixir-cldr/cldr_dates_times"} in your configuration to check before I publish?

kipcole9 commented 3 years ago

I have published ex_cldr_dates_times version 2.9.3. Please feel free to reopen the issue if you see anything incorrect.