+
Skip to content

Conversation

naoNao89
Copy link
Contributor

@naoNao89 naoNao89 commented Oct 6, 2025

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:

# Before (always English, regardless of locale):
LC_ALL=de_DE.UTF-8 ls -l
-rw-r--r-- 1 user wheel 0 Jan  1  2024 file.txt

# Expected (German format):
-rw-r--r-- 1 user wheel 0 15.01.2024, 10:50 file.txt

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

Locale Format Example
en_US M/D/YY, h:mm AM / M/D/YY 1/15/24, 10:50 AM
de_DE DD.MM.YY, HH:mm / DD.MM.YY 15.01.24, 10:50
ja_JP YYYY/MM/DD HH:mm / YYYY/MM/DD 2024/01/15 10:50
fr_FR DD/MM/YYYY, HH:mm / DD/MM/YYYY 15/01/2024, 10:50
C/POSIX %b %e %H:%M / %b %e %Y Jan 15 10:50

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.

Copy link

github-actions bot commented Oct 6, 2025

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/timeout/timeout (passes in this run but fails in the 'main' branch)

@sylvestre
Copy link
Contributor

needs tests

@naoNao89 naoNao89 marked this pull request as draft October 6, 2025 11:55
@naoNao89 naoNao89 force-pushed the feat/ls-locale-time-format branch from 074831b to 11c49cc Compare October 6, 2025 18:22
Copy link

github-actions bot commented Oct 6, 2025

GNU testsuite comparison:

Skip an intermittent issue tests/timeout/timeout (fails in this run but passes in the 'main' branch)

Copy link

codspeed-hq bot commented Oct 6, 2025

CodSpeed Performance Report

Merging #8827 will improve performances by 63.22%

Comparing naoNao89:feat/ls-locale-time-format (696666c) with main (36ca7bc)

Summary

⚡ 4 improvements
✅ 102 untouched
⏩ 73 skipped1

Benchmarks breakdown

Benchmark BASE HEAD Change
ls_recursive_long_all_balanced_tree[(6, 4, 15)] 139.1 ms 116.2 ms +19.7%
ls_recursive_long_all_deep_tree[(100, 4)] 3.1 ms 2.7 ms +15.75%
ls_recursive_long_all_mixed_tree 4 ms 2.4 ms +63.22%
ls_recursive_long_all_wide_tree[(15000, 1500)] 149.8 ms 128 ms +17.1%

Footnotes

  1. 73 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.

@naoNao89 naoNao89 marked this pull request as ready for review October 7, 2025 11:41
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)

@naoNao89 naoNao89 force-pushed the feat/ls-locale-time-format branch 2 times, most recently from 0b299e1 to 3934fd7 Compare October 13, 2025 00:43
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/misc/tee (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tail/overlay-headers (fails in this run but passes in the 'main' branch)

@naoNao89 naoNao89 force-pushed the feat/ls-locale-time-format branch from 994506a to d3977b4 Compare October 13, 2025 02:42
- 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.
@naoNao89 naoNao89 force-pushed the feat/ls-locale-time-format branch from d3977b4 to 192bdf9 Compare October 13, 2025 02:45
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.
Copy link

GNU testsuite comparison:

GNU test failed: tests/ls/block-size. tests/ls/block-size is passing on 'main'. Maybe you have to rebase?
Skip an intermittent issue tests/misc/tee (fails in this run but passes in the 'main' branch)

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

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载