Skip to content

Comments

date: Fix %x, %X, %r to respect locale settings#11068

Open
abendrothj wants to merge 1 commit intouutils:mainfrom
abendrothj:fix/dateformat
Open

date: Fix %x, %X, %r to respect locale settings#11068
abendrothj wants to merge 1 commit intouutils:mainfrom
abendrothj:fix/dateformat

Conversation

@abendrothj
Copy link
Contributor

Fixes #10284

Previously these format specifiers were hardcoded to US/POSIX defaults, ignoring LC_TIME and LC_ALL. Now they call nl_langinfo to get the locale's actual format strings.

Changes:

  • Add D_FMT, T_FMT, T_FMT_AMPM query functions in locale.rs
  • Expand %x/%X/%r before jiff formatting in date.rs
  • Un-ignore and extend locale tests in test_date.rs

now for ci...

@oech3
Copy link
Contributor

oech3 commented Feb 23, 2026

Please cargo fmt

@abendrothj abendrothj force-pushed the fix/dateformat branch 2 times, most recently from 462cb08 to 032b444 Compare February 23, 2026 09:30
@abendrothj
Copy link
Contributor Author

Please cargo fmt

oops, forgot prehook doesnt work on mac currently

@abendrothj abendrothj force-pushed the fix/dateformat branch 2 times, most recently from aa1ee97 to 0146bba Compare February 23, 2026 09:36
- Add locale.rs functions to query nl_langinfo for D_FMT, T_FMT, T_FMT_AMPM
- Add expand_locale_specifiers() to replace %x, %X, %r with locale formats
- Integrate locale specifier expansion before jiff formatting
- Un-ignore and extend locale tests with graceful degradation
@github-actions
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/pr/bounded-memory (passes in this run but fails in the 'main' branch)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it the expected behavior that the tests pass even without your changes to locale.rs and date.rs?

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.

date - %x format specifier ignores locale settings

3 participants