mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-08 12:32:43 +00:00
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.
18 lines
590 B
TypeScript
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;
|