Files
HealthLog/src/lib/time-constants.ts
T
Marc-André Bombeck a9c327401a fix(insights): key readiness + mood-streak day buckets in user tz
The readiness same-day grouping and the mood-streak anchor/walk both
sliced the UTC instant for their day key, mis-bucketing a late-evening
reading for a logger east or west of UTC. Thread an optional tz (default
Europe/Berlin) through both paths and key the buckets via userDayKey so
the day boundary follows the user's wall clock. Centralise the inline
day-in-ms literal in a shared time-constants module and use it here.
2026-06-20 17:10:36 +02:00

18 lines
590 B
TypeScript

/**
* Shared duration constants in milliseconds.
*
* Replaces the inline `24 * 60 * 60 * 1000` (and friends) scattered across
* the codebase. Centralising the literal keeps the intent readable at the
* call site and removes the off-by-a-zero risk of hand-typing the product.
* Pure module — no imports, safe to use anywhere (server or client).
*/
/** One minute in milliseconds. */
export const MS_PER_MINUTE = 60 * 1000;
/** One hour in milliseconds. */
export const MS_PER_HOUR = 60 * MS_PER_MINUTE;
/** One day in milliseconds. */
export const MS_PER_DAY = 24 * MS_PER_HOUR;