Fix POSIX TZ edge cases: midnight fall-back, sub-hour offsets, quoted names, abolished DST - #5
Merged
Merged
Conversation
…s, numeric zone names and abolished DST
- express each transition in the pre-transition wall clock instead of
adjusting hours by +/-1; fixes zones such as Asia/Beirut (M10.5.0/0)
- omit the hour only when it is 02:00, the POSIX default; the old code
omitted it whenever both rules shared an hour
- render offsets with minutes/seconds (IST-5:30) instead of truncating
- quote non-alphabetic abbreviations (<+03>-3) as POSIX requires
- zones that abolished DST no longer get invented rules
- week ordinal 5 ("last") only when no later same weekday exists
- table-driven tests against tzdata strings, incl. southern hemisphere
- CI: gofmt, vet, race tests on Go 1.19 and stable; publish on release
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
FormatTimeZoneproduced wrong strings for several classes of zone. This rewrites the transition logic and adds table-driven tests checked against the POSIX strings in the IANA tzdata footers.EET-2EEST,M3.5.0/0,M10.4.6/24EET-2EEST,M3.5.0/0,M10.5.0/0IST-5IST-5:30+03-3+03,M1.3.2/6:14:07,M1.1.1/0<+03>-3CET-1CEST,M3.5.0/2,M10.5.0/3CET-1CEST,M3.5.0,M10.5.0/3How
h1--/h2++hacks and fixes fall-backs that cross midnight./0,/0.4.Output change
Rule 1 no longer carries an explicit
/2. Both forms are valid POSIX and parsed identically by every TZ parser I know of, but if a consumer string-compares, it will notice.GetPosixOffsetis unchanged and marked deprecated because it truncates minutes.Tests
go test -race ./...on Go 1.19 and stable via the updated workflow: 13 zones incl. Sydney (southern hemisphere), London (01:00 transition), Beirut, Kolkata, Tokyo, Istanbul, São Paulo, UTC.🤖 Generated with Claude Code