mirror of
https://github.com/hanzoai/calendar.git
synced 2026-10-30 14:46:43 +00:00
* wip * add i18n and essential tests * fix UI and add migration * fixes * add logic on book event * restore comment * remove dev debug box * extract min reschedule notice to util * one more replace * add to disable reschedule component * tidy up state * restore lock * restore file * fix zod utils * respond to cubic feedback * fix type error * unit tests * add zod util * build tests with nul minReshceuldeNotice * fix stuff
16 lines
545 B
TypeScript
16 lines
545 B
TypeScript
export function isWithinMinimumRescheduleNotice(
|
|
bookingStartTime: Date | null,
|
|
minimumRescheduleNotice: number | null
|
|
): boolean {
|
|
if (!minimumRescheduleNotice || minimumRescheduleNotice <= 0 || !bookingStartTime) {
|
|
return false;
|
|
}
|
|
|
|
const now = new Date();
|
|
const bookingStart = new Date(bookingStartTime);
|
|
const timeUntilBooking = bookingStart.getTime() - now.getTime();
|
|
const minimumRescheduleNoticeMs = minimumRescheduleNotice * 60 * 1000;
|
|
|
|
return timeUntilBooking > 0 && timeUntilBooking < minimumRescheduleNoticeMs;
|
|
}
|