Repository navigation
fix(timezone): read full posix rules in TZ="..." - #342
jayhemnani9910 wants to merge 1 commit into
Conversation
Only the STDOFFSET part of a posix rule was parsed. A rule with a DST part (TZ="CET-1CEST,M3.5.0,M10.5.0/3", TZ="EST5EDT") made the whole input invalid, and a quoted name (TZ="<+03>-3") fell through to the IANA lookup and silently became UTC. Keep the STDOFFSET parser for rules that end there, and hand anything else that is not an IANA name to jiff's posix parser. A DST name without a rule gets the US rules, as glibc does. A rule that starts like a posix rule but is broken further on stays an error.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
Merging this PR will degrade performance by 3.32%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ❌ |
parse_epoch_timestamp |
11.4 µs | 11.7 µs | -3.32% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing jayhemnani9910:tz-rule-full-posix (6af316c) with main (d5c7380)
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #342 +/- ##
==========================================
+ Coverage 97.73% 97.75% +0.01%
==========================================
Files 21 21
Lines 4421 4454 +33
Branches 139 139
==========================================
+ Hits 4321 4354 +33
Misses 99 99
Partials 1 1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
The flagged benchmark is |
TZ="..."only parses theSTDOFFSETpart of a posix rule (the TODO onposix). Anything more goes wrong in one of two ways:TZ="CET-1CEST,M3.5.0,M10.5.0/3" 2026-07-01 12:00,TZ="EST5EDT" 2026-07-01 12:00<+03>-3, the form tzdata uses for zones with no abbreviation, e.g. the footer ofEurope/Istanbul) doesn't matchposix, falls through to the IANA lookup and silently becomes UTCThe same rules work when they come from the
TZenv var, since jiff reads those.Now
posixonly takes a rule that ends afterSTDOFFSET, so the simple cases (and their hour/minute clamping) stay as they are. Anything else that isn't an IANA name goes tojiff::tz::TimeZone::posix. A rule that starts like a posix rule but is broken further on (EST5EDT,,EST5EDT,M3.2.0) is still an error, as it is now, instead of falling back to UTC. A DST name with no rule (EST5EDT,XYZ+5ABC) gets the US rules (M3.2.0,M11.1.0), which is what glibc does, so it works without a zoneinfo file of that name. On Ubuntu 26.04 thetzdatapackage doesn't haveEST5EDTanymore, and uutilsdate -d 'TZ="EST5EDT" 2026-07-01 12:00'says invalid date there.Testing:
tz_rulefor DST rules,EST5EDTand quoted names, checking the offset in July and January. They fail without the change. Three broken rules are added to the invalid list.cargo test: all pass, same counts as main.cargo clippy --all-targetsandcargo fmt --checkclean.TZ="RULE" 2026-07-01 12:00and2026-01-01 12:00with GNUdate9.7 for about 30 rules (DST rules withM,Jand day-number dates, quoted names, too-short names, unknown names, hour > 24): all the same now. What's left I didn't touch: glibc accepts broken rules (EST5EDT,, junk after a full rule) that stay an error here, and on the US switch day its default rules give a different hour for non-US offsets (<+03>-3<+04>on 2026-03-08).date(coreutils 865e575) against this branch with a[patch.crates-io]entry and randate -u -d '<rule> 2026-07-01 12:00':<+03>-3gives 09:00 (12:00 with 0.17.0), andCET-1CEST,M3.5.0,M10.5.0/3andEST5EDTgive 10:00 and 16:00 instead of "invalid date". All three now match GNU.UTC+5andEurope/Parisare unchanged.