Repository navigation
Description
Summary
Header dates are always correct as recorded: an offset is only a representation of the same instant. Nothing changes by default, and CLDMV's own config will not set this. The option is a convenience for consumers who want every header date expressed in one zone, plus an optional sweep that rewrites existing dates into that zone.
Behaviour
timezone?: string(CLI--timezone <name>): an IANA zone name (e.g.America/Los_Angeles,UTC). When set, every date fix-headers writes is expressed in that zone: a new header's@Date(from git / filesystem / oldest-wins, per the existingresolveCreatedDatelogic) and@Last modified time. The instant and the epoch in parentheses never change; only the written offset and wall-clock time do, with the correct DST offset for that instant (e.g.-08:00in January,-07:00in July forAmerica/Los_Angeles). Works with both output shapes: the default space form (2026-01-18 20:39:48 -08:00) and the ISO T-form undernormalizeDateFormat. Unset means behaviour identical to today.- Sweep:
convertTimezone?: boolean(CLI--convert-timezone), which requirestimezone(a clear error is thrown if it is set without it). It rewrites existing@Dateand@Last modified timevalues into the zone, keeping the instant. Values whose datetime cannot be parsed are left alone, and so is a date already in the target zone at that instant. - Validation: the zone name is validated with
Intl(aRangeErrorfromnew Intl.DateTimeFormat("en-US", { timeZone })means invalid); an unknown zone throws a clear error. @Last modified timerestamping: the sweep follows the same rule as the existing representation-only rewrites (epoch repair,normalizeDateFormat); the rule is documented in the README.--check: a date shown in a different zone thantimezoneis not drift (same instant); no check is added for it.- README: documents both options, their interaction with
normalizeDateFormat, the DST behaviour, and an example.
Implementation notes
- Date helpers:
src/utils/time.mjs(formatDateWithTimezone,toDatePayload,formatIsoDate,parseHeaderDate) andsrc/header/dates.mjs(normalizeDatePayload,repairDateEpoch,resolveCreatedDate). - Options wired through
src/core/fix-headers.mjsand the CLI parser/help insrc/cli.mjs. - The target-zone offset for an instant is computed with
Intl.DateTimeFormatformatToParts(timeZoneoption), not a hard-coded table.
Tests
America/Los_Angeles on both sides of a DST switch; UTC; a half-hour zone (Asia/Kolkata, +05:30); a +14:00 zone (Pacific/Kiritimati); an invalid zone name; convertTimezone without timezone; the sweep on existing headers in the space form and the T-form; a sweep leaving unparseable dates alone; new-header dates from git in the zone; unset timezone giving identical output. The suite must pass under several process TZ values (UTC, America/Los_Angeles, Asia/Kolkata).
Activity
docs: add the opt-in timezone option (#81) to the v2.0.0 notes
release: v2.0.0 - re-cut the release notes as v2.0.0