refactor: code clean up
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
+7
-7
@@ -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(),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user