From 9af5996163d840bc69988aebf3d025bf2497d172 Mon Sep 17 00:00:00 2001 From: Kip Cole Date: Sun, 23 Jul 2023 15:17:24 +0800 Subject: [PATCH] Fix format: :scientific support. Closes #38 --- CHANGELOG.md | 8 ++++++++ lib/cldr/number/format/options.ex | 6 ++++++ mix.exs | 2 +- test/support/number_format_test_data.exs | 1 + 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a550251..04db1a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## Cldr Numbers v2.31.3 + +This is the changelog for Cldr v2.31.3 released on July 23rd, 2023. For older changelogs please consult the release tag on [GitHub](https://github.com/elixir-cldr/cldr_numbers/tags) + +### Bug Fixes + +* Support `format: :scientific` which is documented but was not implemented as a valid option. Thanks to @petrus-jvrensburg for the report. Closes #38. + ## Cldr Numbers v2.31.2 This is the changelog for Cldr v2.31.2 released on July 7th, 2023. For older changelogs please consult the release tag on [GitHub](https://github.com/elixir-cldr/cldr_numbers/tags) diff --git a/lib/cldr/number/format/options.ex b/lib/cldr/number/format/options.ex index 1bce7fc..1d9ed47 100644 --- a/lib/cldr/number/format/options.ex +++ b/lib/cldr/number/format/options.ex @@ -17,6 +17,7 @@ defmodule Cldr.Number.Format.Options do :locale, :number_system, :currency, + :scientific, :format, :currency_format, :currency_digits, @@ -59,6 +60,7 @@ defmodule Cldr.Number.Format.Options do :standard, :accounting, :currency, + :scientific, :percent, :currency_no_symbol, :accounting_no_symbol, @@ -397,6 +399,10 @@ defmodule Cldr.Number.Format.Options do end end + defp validate_option(:scientific, _options, _backend, nil) do + {:ok, :scientific} + end + # If a currency code is provided but no format then a currency # format is forced. diff --git a/mix.exs b/mix.exs index a59179d..fb18102 100644 --- a/mix.exs +++ b/mix.exs @@ -3,7 +3,7 @@ defmodule Cldr.Numbers.Mixfile do use Mix.Project - @version "2.31.2" + @version "2.31.3" def project do [ diff --git a/test/support/number_format_test_data.exs b/test/support/number_format_test_data.exs index adfee38..7594032 100644 --- a/test/support/number_format_test_data.exs +++ b/test/support/number_format_test_data.exs @@ -92,6 +92,7 @@ defmodule Cldr.Test.Number.Format do {12.34, "1.234E1", [format: "#E0"]}, {123.4, "1.234E2", [format: "#E0"]}, {1234, "1.234E3", [format: "#E0"]}, + {1234, "1.234E3", [format: :scientific]}, # Scientific with exponent sign {1234, "1.234E+3", [format: "#E+0"]},