From 4895fc4f3d5fcfd0b8948add7a4102f1e93fe950 Mon Sep 17 00:00:00 2001 From: Hristo Nedelkov Date: Sat, 16 Sep 2023 06:24:51 +0300 Subject: [PATCH] Update utilities.ts --- src/utilities.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/utilities.ts b/src/utilities.ts index 56230e26..d99c6768 100644 --- a/src/utilities.ts +++ b/src/utilities.ts @@ -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()] +} \ No newline at end of file