mirror of https://github.com/wayvr-org/wayvr.git
Used locale in chrono
This commit is contained in:
parent
6f9ca5b3b7
commit
12ceebec6d
|
|
@ -932,6 +932,7 @@ dependencies = [
|
|||
"iana-time-zone",
|
||||
"js-sys",
|
||||
"num-traits",
|
||||
"pure-rust-locales",
|
||||
"wasm-bindgen",
|
||||
"windows-link 0.2.1",
|
||||
]
|
||||
|
|
@ -4194,6 +4195,12 @@ dependencies = [
|
|||
"syn 2.0.113",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pure-rust-locales"
|
||||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "869675ad2d7541aea90c6d88c81f46a7f4ea9af8cd0395d38f11a95126998a0d"
|
||||
|
||||
[[package]]
|
||||
name = "pxfm"
|
||||
version = "0.1.27"
|
||||
|
|
@ -6314,6 +6321,7 @@ dependencies = [
|
|||
"mint",
|
||||
"openxr",
|
||||
"ovr_overlay",
|
||||
"pure-rust-locales",
|
||||
"regex",
|
||||
"rosc",
|
||||
"rust-embed",
|
||||
|
|
|
|||
|
|
@ -44,7 +44,8 @@ xdg.workspace = true
|
|||
|
||||
ash = "^0.38.0" # must match vulkano
|
||||
bytes = { version = "1.11.1" }
|
||||
chrono = "0.4.42"
|
||||
chrono = { version = "0.4.42", features = [ "unstable-locales"]}
|
||||
pure-rust-locales = "0.8.2"
|
||||
chrono-tz = "0.10.4"
|
||||
config = "0.15.19"
|
||||
dbus = { version = "0.9.9" }
|
||||
|
|
|
|||
|
|
@ -220,9 +220,24 @@ fn clock_on_tick(
|
|||
common: &mut event::CallbackDataCommon,
|
||||
data: &mut event::CallbackData,
|
||||
) {
|
||||
let locale = {
|
||||
let binding = common.i18n();
|
||||
let locale = binding.get_locale();
|
||||
match pure_rust_locales::Locale::try_from(locale.to_string().as_str()) {
|
||||
Ok(loc) => loc,
|
||||
Err(_) => pure_rust_locales::Locale::en_US,
|
||||
}
|
||||
};
|
||||
let date_time = state.timezone.as_ref().map_or_else(
|
||||
|| format!("{}", Local::now().format(&state.format)),
|
||||
|tz| format!("{}", Local::now().with_timezone(tz).format(&state.format)),
|
||||
|| format!("{}", Local::now().format_localized(&state.format, locale)),
|
||||
|tz| {
|
||||
format!(
|
||||
"{}",
|
||||
Local::now()
|
||||
.with_timezone(tz)
|
||||
.format_localized(&state.format, locale)
|
||||
)
|
||||
},
|
||||
);
|
||||
|
||||
let label = data.obj.get_as_mut::<WidgetLabel>().unwrap();
|
||||
|
|
|
|||
Loading…
Reference in New Issue