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

UnresolvedFormat error when converting time intervals that span noon to strings #22

Closed bryanlep closed 3 years ago

bryanlep commented 3 years ago

Hello, I want to start by saying thanks for this awesome library!

I've encountered an issue after updating to version 2.7.1. Using Cldr.Time.Interval.to_string/4 where the start time is before noon and the end time is after produces an error when it didn't before, when using DateTime structs. Here's a simple example:

Cldr.Time.Interval.to_string(~U[2021-05-06 11:45:00Z], ~U[2021-05-06 12:15:00Z], MyApp.Cldr, format: :bhm)

produces:

{:error,
 {Cldr.DateTime.UnresolvedFormat,
  "The interval format %{b: [\"h:mm B – \", \"h:mm B\"], h: [\"h:mm – \", \"h:mm B\"], m: [\"h:mm – \", \"h:mm B\"]} is invalid. Valid formats are [:long, :medium, :short] or an interval format string."}}

I have verified that version 2.7.0 does not emit this error and formats the string correctly.

kipcole9 commented 3 years ago

@bryanlep, sorry for the inconvenience. Thats a very unpleasant regression. Will work on it and have a fix in the next 12 hours.

kipcole9 commented 3 years ago

As of commit 1fee73 I believe the regression is fixed. I have published ex_cldr_dates_times version 2.7.2 with the changelog entry:

Bug Fixes

Apologies again for the regression, thats for the report and collaboration.

bryanlep commented 3 years ago

No worries, thanks for the quick fix!