fix(format date): resolve %r when the locale's am/pm fallback also carries %O - #18924
Merged
fdncred merged 1 commit intoAug 28, 2026
Merged
Conversation
…rries %O Follow-up to nushell#18918. Two of the affected locales still failed. `az_IR` and `fa_IR` have an empty `t_fmt_ampm`, so nushell#18918 left `%r` alone for chrono to resolve, the way `de_DE`/`fr_FR`/`nl_NL` need. But chrono's fallback for an empty am/pm form is the locale's `t_fmt`, and for these two that is `%OH:%OM:%OS` — the modifier comes straight back in, and `format date %r` stays `nu::shell::type_mismatch, invalid format`. Substituting `t_fmt` ourselves when `t_fmt_ampm` is empty makes the same fallback chrono makes, but through the stripping path. `de_DE`, `fr_FR` and `nl_NL` are byte-identical (their `t_fmt` is `%T`). While checking this, the full set of locales carrying `%E`/`%O` in `LC_TIME` turned out to be nine, not the two named in nushell#18918: `az_IR`, `fa_IR`, `lo_LA`, `lzh_TW`, `mnw_MM`, `my_MM`, `or_IN`, `shn_MM`, `th_TH`. A test now renders `%x`, `%X`, `%c` and `%r` under all nine. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Contributor
|
Next PR, tell your llm to be less verbose. Thanks |
Contributor
|
I'd love to switch away from |
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.
Description
Follow-up to #18918.
az_IRandfa_IRhave an emptyt_fmt_ampm, so #18918 leaves%rto chrono, the carve-out that keepsde_DEfrom rendering blank. But chrono's fallback for an empty am/pm form is the locale'st_fmt, and for those two that is%OH:%OM:%OS, so the modifier walks back in and%rstill errors.The fix makes chrono's own fallback explicit: when
t_fmt_ampmis empty, substitutet_fmtourselves so it goes through the stripping path.de_DE,fr_FRandnl_NLare byte-identical, theirt_fmtis%T.#18918 also named the wrong set of affected locales. Scanning every
LC_TIMEblock inpure-rust-locales0.8.2 it is nine, not two:az_IR,fa_IR,lo_LA,lzh_TW,mnw_MM,my_MM,or_IN,shn_MM,th_TH. Stripping already covered seven of them; a test now pins all nine so a locale table bump cannot quietly break one.Mutation-checked: dropping the fallback turns three tests red with
TypeMismatch { err_message: "invalid format" }. Green,cargo test -p nu-command --lib814 passed and--test tests2930 passed, fmt and clippy clean. Linux, Rust stable,nu-commandonly.User-facing changes (Release notes)
format date %rnow works under the last two locales that still failed#18918 fixed
format dateunder locales whose formats use%E/%O, butaz_IRandfa_IRstill failed on%r, because they define no am/pm format and their plain time format carries the modifier again:Every other locale, including
de_DE,fr_FRandnl_NL, renders exactly as before.Additional notes
Follow-up to #18918, which fixed #15266. Upstream fix: chronotope/chrono#1816.