feat(calendar): add Nivo data adapter and verify durable API behavior
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user