import { toIsoSqlUTC } from '../../src/utils/datetime'; export function toIsoSql(d: Date = new Date()): string { return toIsoSqlUTC(d); } export { toIsoSqlUTC }; export function ymdInTZ(d: Date, tz: string = 'Europe/Madrid'): string { const parts = new Intl.DateTimeFormat('en-GB', { timeZone: tz, year: 'numeric', month: '2-digit', day: '2-digit', }).formatToParts(d); const get = (t: string) => parts.find(p => p.type === t)?.value || ''; return `${get('year')}-${get('month')}-${get('day')}`; } export function addDaysToYMD(ymd: string, days: number, tz: string = 'Europe/Madrid'): string { const [Y, M, D] = ymd.split('-').map(n => parseInt(n, 10)); const base = new Date(Date.UTC(Y, (M || 1) - 1, D || 1)); base.setUTCDate(base.getUTCDate() + days); return ymdInTZ(base, tz); }