fix: harden booking and meeting flows
This commit is contained in:
@@ -2,6 +2,15 @@ const BERLIN_TZ = "Europe/Berlin";
|
||||
|
||||
export type CalendarDate = { year: number; month: number; day: number };
|
||||
|
||||
/** Strict calendar input, interpreted in Berlin regardless of server TZ. */
|
||||
export function parseBerlinDate(value: string): Date | null {
|
||||
if (!/^\d{4}-\d{2}-\d{2}$/.test(value)) return null;
|
||||
const [year, month, day] = value.split("-").map(Number);
|
||||
if (year < 1000 || month < 1 || month > 12 || day < 1 || day > 31) return null;
|
||||
const date = berlinWallTimeToUTC({ year, month, day }, 0, 0);
|
||||
return berlinDateKey(date) === value ? date : null;
|
||||
}
|
||||
|
||||
export function berlinDateKey(date: Date): string {
|
||||
const { year, month, day } = berlinParts(date);
|
||||
return `${year}-${String(month).padStart(2, "0")}-${String(day).padStart(2, "0")}`;
|
||||
|
||||
Reference in New Issue
Block a user