Skip to content

Support file-backed TZ values - #2247

Open
fzlzjerry wants to merge 1 commit into
johnkerl:mainfrom
fzlzjerry:fix/1406-file-backed-tz
Open

Support file-backed TZ values#2247
fzlzjerry wants to merge 1 commit into
johnkerl:mainfrom
fzlzjerry:fix/1406-file-backed-tz

Conversation

@fzlzjerry

Copy link
Copy Markdown

Summary

Fixes #1406.

Allow TZ to name an absolute TZif file, with an optional leading colon, and accept colon-prefixed zone names. This applies at startup, through --tz, and when the DSL changes ENV["TZ"].

Keep the explicit validation rather than relying only on Go's cached time.Local: invalid names/files still report the existing diagnostic, and timezone changes still take effect within a running process. Files are loaded through time.LoadLocationFromTZData, preserving transition rules, with the same 10 MiB file-size limit as Go's timezone loader. Explicit timezone arguments to individual functions remain name-based.

The troubleshooting template and generated page now describe the supported file forms instead of the previous workaround. Unrelated generated date, platform, and numeric-output changes are not included.

Validation

  • 22 focused unit cases: ten fail on the original implementation and twelve controls already pass; all pass with the fix. Coverage includes transition rules, file reloading, spaces/Unicode in paths, malformed/missing files, unchanged state after errors, and the file-size boundary.
  • Three added CLI regressions fail against the original binary; the complete 62-case local-time regression group passes with the fix.
  • make dev completes: build, unit tests, all 4,796 CLI regression cases, man-page generation, and documentation generation/build.
  • Full package race tests pass on Go 1.26.8 and 1.27.1, with 369 passing test/subtest observations on each. go vet passes on Go 1.27.1.
  • make lint with the CI-pinned golangci-lint 2.12.2 reports 0 issues.
  • 81 additional actual CLI checks exercise inherited TZ, --tz, runtime changes, normal CSV processing, invalid-value controls, symlinks, and winter/summer conversion using a real timezone file. The two changed functions have 100% statement coverage in the Go 1.26.8 test run.

Load absolute TZif paths and normalize one optional leading colon while preserving invalid-zone diagnostics and mid-process timezone updates.

Fixes johnkerl#1406.
Copilot AI lite review requested due to automatic review settings September 9, 2026 18:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@johnkerl johnkerl left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beautiful, thank you @fzlzjerry !

@johnkerl

johnkerl commented Sep 9, 2026

Copy link
Copy Markdown
Owner

I'll take a look at the Windows-only CI fails.

@fzlzjerry

Copy link
Copy Markdown
Author

Thanks, @johnkerl, for the review and for taking the Windows CI investigation. I’ll keep this branch focused on the file-backed TZ change; please let me know if the Windows investigation identifies a correction needed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mlr: TZ environment variable appears malformed when using filename for TZ env var

3 participants