Formatting Data#
Formatting Currencies#
import { formatCurrency } from "@tinka/content";| formatCurrency | input: number | options: formatCurrencyOptions |
|---|---|---|
any number that you wish to format. The function does not convert cents. Passing 1 means 1 euro, dollar... etc. | an optional object to customise the formatting. |
The function rounds incoming values to the second decimal place. An input of 1.999 will have the same output of using 2 as the input.
FormatCurrencyOptions#
| property | type | description |
|---|---|---|
| thousandsSeparator | string | The string used as the thousands separator. It's , in the US and . in the Netherlands. |
| decimalSeparator | string | The string used as the decimal separator. It's . in the US and , in the Netherlands. |
| currencySymbol | string | The string will prepend to the formatted value. Example: € or EUR , not the space here. |
| roundFigureSymbol | string | In some countries, a dash is used when the fractional part of a value is zero. Pass an empty string to disable this substitution. |
| noCents | boolean | The output will not have the fractional part of the formatted value. (Note: the built-in rounding still applies) |
formatCurrencyPresets#
Presets can be imported by:
import { formatCurrencyPresets } from "@tinka/content";Formatting Date#
We recommend using the package date-fns and use the nl locale for the Netherlands.