Skip to content

Work / DwarSeva Societies / Wiki / Concepts

time-handling

Conceptcanonicalverified 2026-10-04

CONCEPT.TIME-HANDLING

Summary

Code never calls new Date(); all time is created, parsed, formatted and compared through core/utils/time.

Why it matters

The server stores UTC and three clients render it — a phone in the resident's zone, a browser in the admin's, and a server with no zone. A native Date built on one of them is silently in that machine's zone, and a visitor's expected arrival moves by hours.

Implications

  • Now: nowUtc() or nowZoned(). Parse: parseDate(). Format: formatUtc(), formatZoned(), formatMobile*(). Arithmetic: addMs(), addSecs(). Ranges: normalizeRange().
  • The mobile "Add visitor" form takes the arrival time as typed text (YYYY-MM-DD HH:MM) and parses it with parseDate(); there is no date picker. See create-visitor.
  • Known exception in the code: apps/mobile/src/app/(roles)/resident/(tabs)/home.tsx formats a bill's due date with toDateOrNull(...)?.toDateString(), a native formatter.

Related

Sources

  • AGENTS.md — "Date & time handling"
  • packages/core/utils