Uh oh!
There was an error while loading. Please reload this page.
date: re-zone trailing TZ abbreviation input to local timezone - #12327
Conversation
The dedicated abbreviation-aware path `try_parse_with_abbreviation` in `src/uu/date/src/date.rs` returned a `Zoned` in the input abbreviation timezone (e.g. `-05` for `EST`). The generic `parse_datetime` fallback already re-zones to `now.time_zone()` for display, so identical inputs took two divergent code paths and only one matched GNU `date`. GNU treats a trailing TZ abbreviation as describing the *input* timezone; the output is always re-zoned into the local zone (or UTC under `-u`). For example, under `TZ=UTC`: $ date -d "2024-01-01 EST" # GNU Mon Jan 1 05:00:00 UTC 2024 uutils previously emitted `Mon Jan 1 00:00:00 -05 2024`. Convert the parsed instant to `now.time_zone()` before returning, matching the fallback path and GNU’s behavior. `-u` still works because `now` is already zoned to UTC in that case (date.rs:362), and the final output stage still applies `with_time_zone(TimeZone::UTC)` when `settings.utc` is set. Un-ignores the existing regression test for this issue. Fixesuutils/parse_datetime#281.
GNU testsuite comparison: |
Merging this PR will improve performance by 13.71%
|
| Mode | Benchmark | BASE | HEAD | Efficiency | |
|---|---|---|---|---|---|
| ⚡ | Simulation | ls_recursive_balanced_tree[(6, 4, 15)] | 50.9 ms | 48.9 ms | +4.01% |
| ⚡ | Memory | cp_recursive_deep_tree[(120, 4)] | 699.2 KB | 562.5 KB | +24.31% |
Tip
Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.
Comparing 0xSoftBoi:fix/281-trailing-tz-abbrev-rezones (3783654) with main (d09f351)
Footnotes
46 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
sylvestre
commented
May 16, 2026
nice, thanks |
Uh oh!
There was an error while loading. Please reload this page.
…s#12327) The dedicated abbreviation-aware path `try_parse_with_abbreviation` in `src/uu/date/src/date.rs` returned a `Zoned` in the input abbreviation timezone (e.g. `-05` for `EST`). The generic `parse_datetime` fallback already re-zones to `now.time_zone()` for display, so identical inputs took two divergent code paths and only one matched GNU `date`. GNU treats a trailing TZ abbreviation as describing the *input* timezone; the output is always re-zoned into the local zone (or UTC under `-u`). For example, under `TZ=UTC`: $ date -d "2024-01-01 EST" # GNU Mon Jan 1 05:00:00 UTC 2024 uutils previously emitted `Mon Jan 1 00:00:00 -05 2024`. Convert the parsed instant to `now.time_zone()` before returning, matching the fallback path and GNU’s behavior. `-u` still works because `now` is already zoned to UTC in that case (date.rs:362), and the final output stage still applies `with_time_zone(TimeZone::UTC)` when `settings.utc` is set. Un-ignores the existing regression test for this issue. Fixesuutils/parse_datetime#281.
Summary
try_parse_with_abbreviationinsrc/uu/date/src/date.rsreturned aZonedin the input abbreviation timezone (e.g.-05forEST). The genericparse_datetimefallback already re-zones tonow.time_zone()for display, so identical inputs took two divergent paths and only one matched GNUdate.GNU treats a trailing TZ abbreviation as describing the input timezone; the output is always re-zoned into the local zone (or UTC under
-u). UnderTZ=UTC:What changed
The abbreviation-aware path now does the same
with_time_zone(now.time_zone().clone())re-zoning the generic fallback already does.-ustill produces UTC output becausenowis zoned to UTC in that case (date.rs:362), and the final output stage still applieswith_time_zone(TimeZone::UTC)whensettings.utcis set, so the existing-u+ abbreviation tests (test_date_utc_with_d_flag,test_date_tz_abbreviation_fixed_offset_outside_season) are unchanged.Testing
tests/by-util/test_date.rsalready contained an#[ignore]d regression test for this issue; this PR un-ignores it. Fulluu_datetest suite is green locally:Fixesuutils/parse_datetime#281.