Skip to content

Commit c556ee0

Browse files
committed
sort: fix month parsing for C/POSIX locale
1 parent 66e7f8c commit c556ee0

File tree

1 file changed

+8
-1
lines changed
  • src/uucore/src/lib/features/i18n

1 file changed

+8
-1
lines changed

src/uucore/src/lib/features/i18n/month.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,14 @@ fn get_month_names() -> &'static Vec<(String, u8)> {
4444
static MONTH_NAMES: OnceLock<Vec<(String, u8)>> = OnceLock::new();
4545
MONTH_NAMES.get_or_init(|| {
4646
let loc = get_time_locale().0.clone();
47-
load_month_names(&loc)
47+
// For undefined locale (C/POSIX), ICU returns generic month names like "M01", "M02"
48+
// which aren't useful for matching. Skip directly to English fallback.
49+
let result = if loc == locale!("und") {
50+
None
51+
} else {
52+
load_month_names(&loc)
53+
};
54+
result
4855
.or_else(|| load_month_names(&locale!("en")))
4956
.expect("ICU should always have English month data")
5057
})

0 commit comments

Comments
 (0)