Work / DwarSeva / Wiki / Concepts
time-handling
Conceptcanonicalverified 2026-10-04
CONCEPT.TIME-HANDLINGSummary
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()ornowZoned(). 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 withparseDate(); there is no date picker. See create-visitor. - Known exception in the code:
apps/mobile/src/app/(roles)/resident/(tabs)/home.tsxformats a bill's due date withtoDateOrNull(...)?.toDateString(), a native formatter.
Related
Sources
- AGENTS.md — "Date & time handling"
- packages/core/utils