diff --git a/CHANGELOG.md b/CHANGELOG.md index 7884140..a1cc5e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ **Note that `ex_cldr_dates_times` version 2.18.0 and later are supported on Elixir 1.12 and later only.** +## Cldr_Dates_Times v2.18.1 + +This is the changelog for Cldr_Dates_Times v2.18.1 released on July 1st, 2024. For older changelogs please consult the release tag on [GitHub](https://github.com/elixir-cldr/cldr_cldr_dates_times/tags) + +### Bug Fixes + +* Fix formatting `am/pm` with format `:narrow` or `:wide`. Thanks to @sysashi for the report. Closes #48. + ## Cldr_Dates_Times v2.18.0 This is the changelog for Cldr_Dates_Times v2.18.0 released on May 29th, 2024. For older changelogs please consult the release tag on [GitHub](https://github.com/elixir-cldr/cldr_cldr_dates_times/tags) diff --git a/lib/cldr/format/date_time_formatter.ex b/lib/cldr/format/date_time_formatter.ex index 4dc6b2e..fb96050 100644 --- a/lib/cldr/format/date_time_formatter.ex +++ b/lib/cldr/format/date_time_formatter.ex @@ -1883,6 +1883,9 @@ defmodule Cldr.DateTime.Formatter do iex> Cldr.DateTime.Formatter.period_am_pm %{hour: 21, minute: 0} "PM" + iex> Cldr.DateTime.Formatter.period_am_pm %{hour: 21, minute: 0}, 5 + "p" + """ @spec period_am_pm(Calendar.time(), integer, Keyword.t()) :: String.t() | {:error, String.t()} @@ -1904,6 +1907,11 @@ defmodule Cldr.DateTime.Formatter do def period_am_pm(time, n, locale, backend, options \\ %{}) + def period_am_pm(%{calendar: Calendar.ISO} = time, n, locale, backend, options) do + %{time | calendar: Cldr.Calendar.Gregorian} + |> period_am_pm(n, locale, backend, options) + end + def period_am_pm(time, n, locale, backend, options) when n in 1..3 do time |> Cldr.Calendar.localize(:am_pm, :format, :abbreviated, backend, locale) diff --git a/mix.exs b/mix.exs index edfe9cc..908a70b 100644 --- a/mix.exs +++ b/mix.exs @@ -1,7 +1,7 @@ defmodule Cldr.DatesTimes.Mixfile do use Mix.Project - @version "2.18.0" + @version "2.18.1" def project do [