refactor: code clean up

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-07-06 21:09:07 -04:00
parent dea5a61811
commit df531908f3
19 changed files with 594 additions and 643 deletions
+7 -7
View File
@@ -1,4 +1,4 @@
import type { VisibleDateRange } from '../types'
import { EpochSpan } from '@/types/date'
export function parseCalendarDate(value: string | null | undefined): Date | null {
if (!value) return null
@@ -45,17 +45,17 @@ export function shiftLocalMonths(date: Date, months: number): Date {
return shifted
}
export function daysVisibleRange(date: Date, days: number): VisibleDateRange {
export function daysVisibleRange(date: Date, days: number): EpochSpan {
const start = startOfLocalDay(date)
const end = shiftLocalDays(start, Math.max(1, days))
return {
startMs: start.getTime(),
endMs: end.getTime(),
start: start.getTime(),
end: end.getTime(),
}
}
export function monthGridVisibleRange(date: Date): VisibleDateRange {
export function monthGridVisibleRange(date: Date): EpochSpan {
const firstDay = new Date(date.getFullYear(), date.getMonth(), 1)
const gridStart = new Date(firstDay)
gridStart.setDate(gridStart.getDate() - gridStart.getDay())
@@ -65,7 +65,7 @@ export function monthGridVisibleRange(date: Date): VisibleDateRange {
const gridEnd = shiftLocalDays(gridStart, weeks * 7)
return {
startMs: gridStart.getTime(),
endMs: gridEnd.getTime(),
start: gridStart.getTime(),
end: gridEnd.getTime(),
}
}