/** * Deterministic clock for Storybook stories. * * Stories that render relative timestamps ("3m ago", "yesterday") must use these * helpers instead of `new Date()` / `Date.now()`, or visual diffs in Chromatic * will drift on every run. * * FROZEN_NOW is the reference instant. Helpers below produce timestamps relative * to it so the rendered output is identical regardless of when the build runs. */ export const FROZEN_NOW = new Date('2026-01-15T12:00:00.000Z') const MS_PER_SEC = 1000 const MS_PER_MIN = 60 * MS_PER_SEC const MS_PER_HOUR = 60 * MS_PER_MIN const MS_PER_DAY = 24 * MS_PER_HOUR export const now = (): Date => new Date(FROZEN_NOW) export const secondsAgo = (n: number): Date => new Date(FROZEN_NOW.getTime() - n * MS_PER_SEC) export const minutesAgo = (n: number): Date => new Date(FROZEN_NOW.getTime() - n * MS_PER_MIN) export const hoursAgo = (n: number): Date => new Date(FROZEN_NOW.getTime() - n * MS_PER_HOUR) export const daysAgo = (n: number): Date => new Date(FROZEN_NOW.getTime() - n * MS_PER_DAY)