Skip to content

feat: opt-in timezone option and a convertTimezone sweep for header dates #79

Closed

Description

@Shinrai

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

  1. 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 existing resolveCreatedDate logic) 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:00 in January, -07:00 in July for America/Los_Angeles). Works with both output shapes: the default space form (2026-01-18 20:39:48 -08:00) and the ISO T-form under normalizeDateFormat. Unset means behaviour identical to today.
  2. Sweep: convertTimezone?: boolean (CLI --convert-timezone), which requires timezone (a clear error is thrown if it is set without it). It rewrites existing @Date and @Last modified time values 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.
  3. Validation: the zone name is validated with Intl (a RangeError from new Intl.DateTimeFormat("en-US", { timeZone }) means invalid); an unknown zone throws a clear error.
  4. @Last modified time restamping: the sweep follows the same rule as the existing representation-only rewrites (epoch repair, normalizeDateFormat); the rule is documented in the README.
  5. --check: a date shown in a different zone than timezone is not drift (same instant); no check is added for it.
  6. 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) and src/header/dates.mjs (normalizeDatePayload, repairDateEpoch, resolveCreatedDate).
  • Options wired through src/core/fix-headers.mjs and the CLI parser/help in src/cli.mjs.
  • The target-zone offset for an instant is computed with Intl.DateTimeFormat formatToParts (timeZone option), 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

  1. added
    priority: low
    type: feature request
    area: core
    area: cli
    status: in progress
    on Sep 29, 2026
  2. added a commit that references this issue on Sep 29, 2026
  3. added
    status: implemented
    and removed
    status: in progress
    on Sep 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: cliarea: corepriority: lowstatus: implementedtype: feature request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions