first commit
This commit is contained in:
No files matched your search
@@ -0,0 +1,16 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user