Skip to content

Commit

Permalink
Fix format: :scientific support. Closes #38
Browse files Browse the repository at this point in the history
  • Loading branch information
kipcole9 committed Jul 23, 2023
1 parent 6be66b5 commit 9af5996
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
6 changes: 6 additions & 0 deletions lib/cldr/number/format/options.ex
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ defmodule Cldr.Number.Format.Options do
:locale,
:number_system,
:currency,
:scientific,
:format,
:currency_format,
:currency_digits,
Expand Down Expand Up @@ -59,6 +60,7 @@ defmodule Cldr.Number.Format.Options do
:standard,
:accounting,
:currency,
:scientific,
:percent,
:currency_no_symbol,
:accounting_no_symbol,
Expand Down Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ defmodule Cldr.Numbers.Mixfile do

use Mix.Project

@version "2.31.2"
@version "2.31.3"

def project do
[
Expand Down
1 change: 1 addition & 0 deletions test/support/number_format_test_data.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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"]},
Expand Down

0 comments on commit 9af5996

Please sign in to comment.