aboutsummaryrefslogtreecommitdiff
path: root/src/lib/format.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/format.ts')
-rw-r--r--src/lib/format.ts9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/lib/format.ts b/src/lib/format.ts
new file mode 100644
index 0000000..28aa50f
--- /dev/null
+++ b/src/lib/format.ts
@@ -0,0 +1,9 @@
+export function decimal(n: number): string {
+ const str = n.toString()
+ const xs = str.split('.')
+ if (xs.length == 2) {
+ return `${xs[0]},${xs[1].slice(0, 2).padEnd(2, '0')}`
+ } else {
+ return `${str},00`
+ }
+}