Skip to content

fix: keep the last decimal separator when unformatting values - #247

Open
DeoJin wants to merge 1 commit into
openexchangerates:masterfrom
DeoJin:fix/issue-240-unformat-currency-decimal
Open

fix: keep the last decimal separator when unformatting values#247
DeoJin wants to merge 1 commit into
openexchangerates:masterfrom
DeoJin:fix/issue-240-unformat-currency-decimal

Conversation

@DeoJin

@DeoJin DeoJin commented Mar 16, 2026

Copy link
Copy Markdown

Summary

  • make unformat() ignore extra decimal separator characters left behind by currency symbols like kr.
  • preserve the final decimal separator so values such as kr. 123.45 parse as 123.45
  • add a regression test covering the reported Swedish krona example

Validation

  • node -e "const assert=require(''assert''); const accounting=require(''./accounting.js''); assert.strictEqual(accounting.unformat(''kr. 123.45'',''.''),123.45); assert.strictEqual(accounting.unformat(''$ 123,456.78''),123456.78); assert.strictEqual(accounting.unformat(''$ 123,456'','',''),123.456); console.log(''ok'');"

Fixes #240

@DeoJin DeoJin changed the title fix: keep the last decimal separator when unformating values fix: keep the last decimal separator when unformatting values Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

unformat() returns the wrong value if currency symbol contains the decimal separator

1 participant