Parse DKK with locale da fails
Closed this issue ยท 3 comments
Hey Kip,
As far as I understand this should work:
iex(1)> Cldr.Currency.strings_for_currency :DKK, "da", MyApp.Cldr
["kr", "dkk", "danske kroner", "dansk krone"]
iex(2)> {:ok, s} = Money.to_string(Money.new(:DKK, 4200), locale: "da")
{:ok, "4.200,00 kr."}
iex(3)> Money.parse(s, locale: "da")
{:error, {Money.ParseError, "Could not parse \"4.200,00 kr.\"."}}
The dot in "kr." is the culprit:
iex(4)> Money.parse("4.200,00 kr", locale: "da")
#Money<:DKK, 4200.00>
I have a hard time finding an authoritative reference for it, but I believe including the dot is the correct currency sign in the danish locale.
I agree, i would expect that any of the Cldr.Currency.strings_for_currency/3
strings would be acceptable when parsing. I will work on a fix but it might be a couple of days. Let me know if that's ok for you - if you need a fix in a hurry I will see if I can change some priorities.
A couple of days is phenomenal support time for an open source project! ๐
This commit fixes the parsing issue. I have published ex_money version 5.5.3 which has the following changelog entry:
Bug Fixes
- Fixes parsing money when a currency string has a "." in it such as "kr.". Thanks for the report to @Doerge. Closes #125.
Thanks for the report and sorry for the inconvenience.