const ISO_DAY_PATTERN = /^\d{4}-\d{2}-\d{2}/; const ISO_DAY_LENGTH = "YYYY-MM-DD".length; /** * True when two ISO dates or datetimes fall on the same day. BookOrbit knows only the day of a * start or finish, while BookHive keeps the time of day, so a whole timestamp never matches. */ export function isSameIsoDay(a: unknown, b: unknown): boolean { if (typeof a !== "string" || typeof b !== "string") return false; if (!ISO_DAY_PATTERN.test(a) || !ISO_DAY_PATTERN.test(b)) return false; return a.slice(0, ISO_DAY_LENGTH) === b.slice(0, ISO_DAY_LENGTH); }