fix(date): support timezone abbreviations in date --set`#8944
Merged
sylvestre merged 2 commits intouutils:mainfrom Oct 26, 2025
Merged
fix(date): support timezone abbreviations in date --set`#8944sylvestre merged 2 commits intouutils:mainfrom
sylvestre merged 2 commits intouutils:mainfrom
Conversation
Fixes uutils#1882 Implements dynamic timezone abbreviation resolution with minimal hardcoding: - Dynamically discovers 588+ IANA timezones and their abbreviations - Only 11 hardcoded disambiguations for truly ambiguous cases (CST, EST, IST, etc.) - US timezone preferences for GNU compatibility - Comprehensive test coverage including Australian, Asian, European, and US timezones All date --set formats now work correctly.
4e4e8ef to
49c3386
Compare
|
GNU testsuite comparison: |
6893d9e to
16b3865
Compare
|
GNU testsuite comparison: |
sylvestre
reviewed
Oct 18, 2025
| /// - GMT: Alias for UTC (universal) | ||
| /// | ||
| /// All other timezones (AWST, JST, CET, etc.) are dynamically resolved from IANA database. // spell-checker:disable-line | ||
| static PREFERRED_TZ_MAPPINGS: &[(&str, &str)] = &[ |
Contributor
There was a problem hiding this comment.
not sure we should maintain such list.
Seems that @BurntSushi has this in jiff
https://github.com/BurntSushi/jiff/blob/fdf6ab2978f49e0ac1154d78dd1c440965020506/src/fmt/rfc2822.rs#L875
maybe use that instead, no ?
There was a problem hiding this comment.
Note that for Jiff, the mapping comes straight from RFC 2822. It isn't necessarily GNU compatible and it doesn't map the time zone abbreviations back to IANA time zone identifiers. Just offsets.
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.
Fixes #1882 - a 4-year-old issue where
date --setfailed with timezone abbreviations like AWST, EST, PST.The Problem:
Three tests were marked "expected to fail" since 2021 because the underlying parser couldn't handle timezone abbreviations that GNU date supports.
The Solution:
Instead of hardcoding hundreds of timezones, I built a smart resolution system:
OnceLockfor zero startup costThis means
date --set "Sat 20 Mar 2021 14:53:01 AWST"finally works! The implementation actually goes beyond GNU by supporting additional abbreviations like Australian timezones.