Client: Better locale comma support
This commit is contained in:
10
client/src/utils/parsing.ts
Normal file
10
client/src/utils/parsing.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
|
||||
// Number formatter that nicely formats numbers with correct decimal separator
|
||||
export function numberFormatter(value: number | undefined) {
|
||||
return value ? Number(value).toLocaleString() : "";
|
||||
}
|
||||
|
||||
// Number parser that supports both comma and dot as decimal separator
|
||||
export function numberParser(value: string | undefined) {
|
||||
return Number(value?.replace(",", ".") ?? 0);
|
||||
}
|
||||
Reference in New Issue
Block a user