Files
vitify-nuxt/utils/periodUtils.ts
2025-04-22 10:56:56 +07:00

17 lines
445 B
TypeScript

export interface Period {
start?: Date
end?: Date
}
export function isPeriodActive(period?: Period): boolean {
if (!period) return true // No period means always active
const now = new Date()
const start = period.start ? new Date(period.start) : null
const end = period.end ? new Date(period.end) : null
const isAfterStart = !start || now >= start
const isBeforeEnd = !end || now <= end
return isAfterStart && isBeforeEnd
}