Files
petitspas/backend/src/common/utils/paris-date.ts
T
jmartinandCursor 6835b24670 feat(#216): Agenda B2 — soft-cancel, matrice temporelle, cron, ack arrêt
- Soft-cancel événement/carte (plus de DELETE physique applicatif)
- Matrice : soin [hier–auj.] + 24h ; edit 7×24h ; congé futur libre
- Arrêt accepté dès soumission ; ack parent n’écrit plus sur l’événement
- verrouille_le à la soumission ; revision bump si dates congé
- Cron horaire : auto-valid congés J+7, soft-cancel refusés J+7
- Respond OK après purge_at ; tri fil COALESCE(remonte_le, cree_le)

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-16 17:07:10 +02:00

32 lines
1.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/** Dates calendaires Europe/Paris — comparaison lexicographique YYYY-MM-DD = calendaire (DST-safe). */
const PARIS_YMD = new Intl.DateTimeFormat('en-CA', {
timeZone: 'Europe/Paris',
year: 'numeric',
month: '2-digit',
day: '2-digit',
});
/** Aujourd’hui civil à Paris (YYYY-MM-DD). */
export function todayParis(): string {
return PARIS_YMD.format(new Date());
}
/** Décale une date calendaire YYYY-MM-DD de `deltaDays` (UTC, sans glissement DST). */
export function shiftYmd(ymd: string, deltaDays: number): string {
const [y, m, d] = ymd.split('-').map(Number);
const dt = new Date(Date.UTC(y, m - 1, d + deltaDays));
const yy = dt.getUTCFullYear();
const mm = String(dt.getUTCMonth() + 1).padStart(2, '0');
const dd = String(dt.getUTCDate()).padStart(2, '0');
return `${yy}-${mm}-${dd}`;
}
export function yesterdayParis(): string {
return shiftYmd(todayParis(), -1);
}
/** Fenêtre temporelle exacte en ms (ex. 7×24 h = 168 h). */
export const MS_24H = 24 * 60 * 60 * 1000;
export const MS_7X24H = 7 * MS_24H;