feat(calendar): add Nivo data adapter and verify durable API behavior

This commit is contained in:
syntaxbullet
2026-09-04 09:16:09 +02:00
parent 9a7180ce78
commit ff7ec68262
8 changed files with 232 additions and 11 deletions

View File

@@ -2,8 +2,11 @@ import type { Schedule, CalendarSettings } from './contracts';
const DAY = 86400000;
export const dayNumber = (date: string) => Date.parse(`${date}T00:00:00Z`) / DAY;
export const addDays = (date: string, n: number) => new Date((dayNumber(date) + n) * DAY).toISOString().slice(0, 10);
const dateFormatters = new Map<string, Intl.DateTimeFormat>();
export function localDate(timestamp: number, timezone: string): string {
return new Intl.DateTimeFormat('en-CA', { timeZone: timezone, year: 'numeric', month: '2-digit', day: '2-digit' }).format(timestamp);
let formatter = dateFormatters.get(timezone);
if (!formatter) { formatter = new Intl.DateTimeFormat('en-CA', { timeZone: timezone, year: 'numeric', month: '2-digit', day: '2-digit' }); dateFormatters.set(timezone, formatter); }
return formatter.format(timestamp);
}
// Search an instant boundary rather than adding 24h: DST days can be 23 or 25h.
export function endOfDay(date: string, timezone: string): number {