Skip to content

fix(offset): match GNU timezone behavior - #358

Open
anastygnome wants to merge 2 commits into
uutils:mainfrom
anastygnome:split/offset
Open

anastygnome wants to merge 2 commits into
uutils:mainfrom
anastygnome:split/offset

Conversation

@anastygnome

@anastygnome anastygnome commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Preserve named-zone provenance so local abbreviations retain DST-aware behavior when applicable.
  • Preserve uutils compatibility for named offsets including AEST, AEDT, ACST, ACDT, and AWST.
  • Parse and normalize larger numeric offsets safely, including overflow validation.
  • Keep fixed offsets anchored before relative adjustments.

@codspeed

codspeed Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will degrade performance by 6.2%

3 warnings

⚠️ 13 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

⚠️ 6 benchmarks with a significant change ran on different hardware

Their base and head results were measured on machines with a different CPU, core count or memory, so the changes might not come from the code. Run base and head on the same runner type.

Learn more about Macro Runners

See affected benchmarks

⚠️ 6 benchmarks with a significant change ran in a different software environment

Their base and head results were measured with a different OS or toolchain, such as compiler, runtime or library versions, so the changes might come from this difference rather than from the code. Open an affected benchmark to see what changed.

See affected benchmarks

❌ 6 regressed benchmarks
✅ 15 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
❌ parse_datetime_with_tz_name 62.5 µs 73.1 µs -14.49%
❌ parse_epoch_timestamp 11.5 µs 12.3 µs -6.36%
❌ parse_iso_datetime_t_separator 39.8 µs 41.8 µs -4.81%
❌ parse_iso_datetime 39.7 µs 41.5 µs -4.35%
❌ parse_date_slash_format 26.6 µs 27.6 µs -3.65%
❌ parse_timezone_offset 58.6 µs 60.4 µs -3.02%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing anastygnome:split/offset (7f366f6) with main (c25bfab)

Open in CodSpeed

@codecov

codecov Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.92746% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 98.92%. Comparing base (c25bfab) to head (7f366f6).

Files with missing lines Patch % Lines
src/items/builder.rs 96.07% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #358      +/-   ##
==========================================
- Coverage   98.97%   98.92%   -0.06%     
==========================================
  Files          21       21              
  Lines        4698     4839     +141     
  Branches      143      151       +8     
==========================================
+ Hits         4650     4787     +137     
- Misses         47       51       +4     
  Partials        1        1              
Flag Coverage Δ
macos_latest 98.92% <97.92%> (?)
ubuntu_latest 98.92% <97.92%> (-0.06%) ⬇️
windows_latest 13.22% <41.45%> (+0.83%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@anastygnome

Copy link
Copy Markdown
Contributor Author

@sylvestre can you check real quick

@sylvestre

Copy link
Copy Markdown
Contributor

thanks for looking into this!
This does too much in one PR, and the named-local-zone path drops the GNU day overflow for months/years (see inline).
CodSpeed shows a 5.6% slowdown: matching_local_zone runs strftime on every parse with a named zone. Please fix that and get codecov green.

Comment thread src/items/builder.rs
match rel {
relative::Relative::Years(_)
| relative::Relative::Months(_)
| relative::Relative::Days(_) => date_relative.push(rel),

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.

with a local named zone, months/years now skip the GNU day overflow done in the else branch
e.g. "2026-01-31 EST +1 month" in America/New_York
please add a test

Comment thread src/items/builder.rs
}
} else {
// Apply relative adjustments in their existing order. Calendar
// month/year grouping is handled by the separate relative-fix PR.

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.

please don't reference another PR in a code comment, it will be stale

Comment thread src/items/builder.rs
t.second(),
t.subsec_nanosecond(),
)?;
let named_zone_is_local = self

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.

matching_local_zone is computed here and again at 4d, and offset.name() 3 times
could be done once, no?

Comment thread src/items/builder.rs
.and_then(|offset| offset.name())
.is_some()
{
if let Some(offset) = self.offset.as_ref() {

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.

we already know offset is Some here, do we need this if let?

Comment thread src/items/builder.rs
// zone and then apply the remaining hour correction.
if !use_named_local_zone && !named_fixed_zone_applied {
if let Some(offset) = self.offset {
let (offset, hour_adjustment) = offset.normalize();

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.

why change the order here (to_zoned then hours)?
it changes the result for offsets > 24h, please add a test

Comment thread src/items/builder.rs
local: civil::DateTime,
name: &str,
) -> Option<jiff::tz::TimeZone> {
// GNU's universal abbreviations always denote fixed UTC, even if the

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.

this duplicates the names of the offset table
could it be a flag in Offset instead?

Comment thread tests/date.rs
#[case::acst("2026-07-10 12:00 ACST", "2026-07-10 12:00:00+09:30")]
#[case::acdt("2026-01-10 12:00 ACDT", "2026-01-10 12:00:00+10:30")]
#[case::awst("2026-01-10 12:00 AWST", "2026-01-10 12:00:00+08:00")]
fn test_australian_zone_abbreviation_offsets(#[case] input: &str, #[case] expected: &str) {

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.

is 13:00 EDT what GNU date gives with TZ=America/New_York?

Comment thread src/items/offset.rs
"adt" => (true, 3, 0, false),
"a" => (false, 1, 0, true),
// Australian abbreviations accepted by GNU date.
"aest" => (false, 10, 0, true),

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.

Please split that into two pr: the new abbreviations and the numeric offset changes are independent of the DST work

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.

2 participants