-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
ls: Implement locale-aware time formatting for --time-style=locale #8827
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
GNU testsuite comparison:
|
needs tests |
074831b
to
11c49cc
Compare
GNU testsuite comparison:
|
CodSpeed Performance ReportMerging #8827 will improve performances by 63.22%Comparing Summary
Benchmarks breakdown
Footnotes
|
GNU testsuite comparison:
|
0b299e1
to
3934fd7
Compare
GNU testsuite comparison:
|
994506a
to
d3977b4
Compare
- Replace hardcoded locale mappings with ICU4X-based formatters for --time-style=locale and add comprehensive tests - Stream formatter output via WriteVec to avoid intermediate allocations - Performance: add small LRU cache for repeated timestamps and POSIX fast path that avoids ICU for C/POSIX, and cache locale per-thread - Keep POSIX fallback with English month names for compatibility Includes necessary Cargo.toml/Cargo.lock updates and cspell dictionary entries.
d3977b4
to
192bdf9
Compare
Regenerate fuzz/Cargo.lock so CI steps 'cargo update' and 'Confirm MinSRV compatible */Cargo.lock' pass. This updates only the fuzz crate lockfile and does not modify workspace dependencies or code.
GNU testsuite comparison:
|
Addresses #3997 and partially addresses #1872.
The Problem
ls
always showed dates in hardcoded English format, which is fine if you're in Kansas but somewhat awkward if you're in Deutschland:What This Does
Uses ICU4X with CLDR data for locale-aware formatting. Reads locale from LC_ALL > LC_TIME > LANG (proper POSIX priority), supports 500+ locales, falls back to POSIX format for C/POSIX locale. No more "Jan" when you wanted it in Japanese (spoiler: it's "1月").
New datetime module in src/uucore/src/lib/features/i18n/datetime.rs (~560 lines) handles ICU4X formatting with per-thread caching and zero-allocation streaming. Modified ls.rs to add TimeStyle::Locale alongside existing format-string styles - opt-in only via --time-style=locale.
Example Formats
datetime.rs is completely new infrastructure. In ls.rs, adds new enum variant alongside existing ones - all existing format strings work identically. Unless you explicitly use --time-style=locale, you get exactly the same behavior as before. Standard opt-in extension pattern.