HTML 77.2%
TypeScript 10.5%
Python 9.6%
JavaScript 2.5%
1/** Date helpers for the temporal pages (UTC, YYYY-MM-DD). Server-safe, no data. */2export const ISO_DAY = /^\d{4}-\d{2}-\d{2}$/;34export function todayUtc(): string {5 return new Date().toISOString().slice(0, 10);6}7export function daysBefore(iso: string, days: number): string {8 const d = new Date(`${iso}T00:00:00Z`);9 d.setUTCDate(d.getUTCDate() - days);10 return d.toISOString().slice(0, 10);11}12export function monthsBefore(iso: string, months: number): string {13 const d = new Date(`${iso}T00:00:00Z`);14 d.setUTCMonth(d.getUTCMonth() - months);15 return d.toISOString().slice(0, 10);16}17export function firstOfMonth(iso: string): string {18 return `${iso.slice(0, 7)}-01`;19}20export function firstOfQuarter(iso: string): string {21 const m = Number(iso.slice(5, 7));22 const q = Math.floor((m - 1) / 3) * 3 + 1;23 return `${iso.slice(0, 4)}-${String(q).padStart(2, '0')}-01`;24}25export function validDay(v: string | undefined | null): string | null {26 if (!v || !ISO_DAY.test(v)) return null;27 const d = new Date(`${v}T00:00:00Z`);28 return Number.isNaN(d.getTime()) ? null : v;29}30