staccx / bento

https://bento.stac.cx
5 stars 1 forks source link

FormatCurrency does not work as expected #4

Closed robinsandborg closed 4 years ago

robinsandborg commented 4 years ago

The problem

The documentation for formatCurrency is not in line with the expected output. Not sure if the problem is with the documentation or the function.

Environment

Code To Reproduce Issue

The documentation provides this code:

<CurrencyText>
   {formatCurrency(100000, {
    symbol: "kr",
    format: "$s  $v",
    suffix: ",-"
  })}
   </CurrencyText>

The ouput from this is kr100 000 from the code example I would expect kr 100 000,-

Please share relevant sample code. Or better yet, provide a link to a minimal reproducible example.

XSlemX commented 4 years ago

Suffix is not a part of the options if you look at the function. Not a bug. Will change type

XSlemX commented 4 years ago

I think we might look into removing the accounting dependency. This is pretty simple formatting.

XSlemX commented 4 years ago

@robinsandborg could you create a spec?

XSlemX commented 4 years ago

Leaning towards built in features like Intl.NumberFormat or Number.prototype.toLocaleString. Thoughts?

XSlemX commented 4 years ago

formatNumber and formatMoney landed in https://github.com/staccx/bento/commit/0dcb3d601a0bf0ce3eda9d7ea533a6694de79218