Update utilities.ts

This commit is contained in:
Hristo Nedelkov 2023-09-16 06:24:51 +03:00
parent d70fb531fc
commit 4895fc4f3d
1 changed files with 8 additions and 0 deletions

View File

@ -13,6 +13,8 @@
* assertUnreachable(user.role);
* }
*/
import { DateRange } from 'react-day-picker'
export function assertUnreachable(value: never): never {
throw new Error(`Unreachable case: ${value}`)
}
@ -26,3 +28,9 @@ export const convertSecondsToTimerFormat = (seconds: number) => {
export const formatNumberWithComa = (n: number): string => {
return n.toFixed(3).replace(/\./g, ',')
}
export const getMonthIndicesFromRange = (range: DateRange) => {
if (!range.from || !range.to) return [0, 11]
return [range.from.getMonth(), range.to.getMonth()]
}