-
Notifications
You must be signed in to change notification settings - Fork 533
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
Invalid datetime format for korean(ko_KR
)
#985
Comments
I think you'll need to file an issue against https://github.com/cecton/pure-rust-locales. |
@djc i've looked at pure-rust-locales, it defines korean datetime format as #[test]
fn locale_match_ko_kr() {
let locale = "ko_KR".try_into().unwrap();
let d_fmt = pure_rust_locales::locale_match!(locale => LC_TIME::D_FMT);
assert_eq!(d_fmt, "%Y년 %m월 %d일");
let d_t_fmt = pure_rust_locales::locale_match!(locale => LC_TIME::D_T_FMT);
assert_eq!(d_t_fmt, "%x (%a) %r");
} i've modified pub fn new_with_locale(s: &'a str, locale: Locale) -> StrftimeItems<'a> {
// ...
let d_t_fmt = StrftimeItems::new(locales::d_t_fmt(locale)).collect();
println!("locales: {:?}", locales::d_t_fmt(locale));
println!("d_t_fmt: {:?}", d_t_fmt);
// ...
}
/*
locales: "%x (%a) %r"
d_t_fmt: [Numeric(Month, Zero), Literal("/"), Numeric(Day, Zero), Literal("/"), Numeric(YearMod100, Zero), Space(" "), Literal("("), Fixed(ShortWeekdayName), Literal(")"), Space(" "), Numeric(Hour12, Zero), Literal(":"), Numeric(Minute, Zero), Literal(":"), Numeric(Second, Zero), Space(" "), Fixed(UpperAmPm)]
thread 'format::strftime::test_strftime_localized_korean' panicked at 'assertion failed: `(left == right)`
*/ does parsing assert_eq!(dt.format_localized("%x", Locale::ko_KR).to_string(), "2001년 07월 08일"); will pass. |
Maybe it doesn't? Unfortunately I don't have much time to investigate right now. Would be happy to review a PR if you're able to figure it out! |
Lines 259 to 269 in 43579a5
alright, i'm investigating, and i think i found the cause: for verification, when i changed #[cfg(feature = "unstable-locales")]
fn with_remainer(s: &'a str) -> StrftimeItems<'a> {
println!("with remainer s: {:?}", s);
StrftimeItems {
remainder: s,
recons: Vec::new(),
// d_fmt: D_FMT.to_vec(),
d_fmt: StrftimeItems::new(locales::d_fmt(Locale::ko_KR)).collect(),
d_t_fmt: D_T_FMT.to_vec(),
t_fmt: T_FMT.to_vec(),
}
} |
Fixed in #1165. |
Summary
South korea uses
Year-Month-Day
date format like rest of east asia. however, it's invalidly rendered asMonth-Day-Year
with%c
.To reproduce
(tested in
0.4.23
)The text was updated successfully, but these errors were encountered: