try improve overview

This commit is contained in:
Carl-Gerhard Lindesvärd
2024-02-27 21:40:26 +01:00
parent 7cbdae8929
commit ee2ccbaa98
9 changed files with 198 additions and 80 deletions

View File

@@ -1,16 +1,34 @@
import { round } from '@/utils/math';
import { isNil } from 'ramda';
export function fancyMinutes(time: number) {
const minutes = Math.floor(time / 60);
const seconds = round(time - minutes * 60, 0);
return `${minutes}m ${seconds}s`;
}
export function useNumber() {
const locale = 'en-gb';
const format = (value: number | null | undefined) => {
if (isNil(value)) {
return 'N/A';
}
return new Intl.NumberFormat(locale, {
maximumSignificantDigits: 20,
}).format(value);
};
const short = (value: number | null | undefined) => {
if (isNil(value)) {
return 'N/A';
}
return new Intl.NumberFormat(locale, {
notation: 'compact',
}).format(value);
};
return {
format: (value: number | null | undefined) => {
if (isNil(value)) {
return 'N/A';
}
return new Intl.NumberFormat(locale, {
maximumSignificantDigits: 20,
}).format(value);
},
format,
short,
};
}