-
Notifications
You must be signed in to change notification settings - Fork 590
Closed
chronotope/pure-rust-locales
#12Description
Hi all,
I am trying to format some dates, based on the user's locale
, therefore I am using the localized
base functions. However, when doing a Display
of date, I get unexpected result, or maybe I am missing something?
platform: linux
(ubuntu 20.04)
chrono version: 0.4.31
use chrono::prelude::*;
fn main() {
let locale_nl = Locale::nl_NL;
let locale_us = Locale::en_US;
let local: DateTime<Local> = Local::now();
let fmt_time_nl = local.format_localized("%X", locale_nl);
let fmt_time_us = local.format_localized("%X", locale_us);
let fmt_date_nl = local.format_localized("%x", locale_nl);
let fmt_date_us = local.format_localized("%x", locale_us);
println!("Time NL: {}", fmt_time_nl);
println!("Time US: {}", fmt_time_us);
println!("Date NL: {}", fmt_date_nl);
println!("Date US: {}", fmt_date_us);
....
}
Yields the following output:
Time NL: 20:34:51
Time US: 08
Date NL: 02-11-23
Date US: 11/02/2023
Thus, date seems fine, but not time
.
I saw that I could do '%r' for 12 hour clock time(us locale), which would yield the correct result, and for nl_NL
it would fallback to %X
, but Display
ing just 08
as time seems unexpected. I would expect to also get mins
and secs
, not only h
.
Thanks for your time!
Metadata
Metadata
Assignees
Labels
No labels