Respect user config for military time

Closes: #96
This commit is contained in:
Josh Megnauth 2024-08-29 03:23:40 -04:00
parent ff03667847
commit 912017615c
No known key found for this signature in database
GPG key ID: 70813183462EFAD3
3 changed files with 36 additions and 2 deletions

View file

@ -110,6 +110,8 @@ fn user_data_fallback() -> Vec<UserData> {
theme_opt: None,
wallpapers_opt: None,
xkb_config_opt: None,
clock_military_time: false,
// clock_show_seconds: false,
}
})
.collect()
@ -1025,7 +1027,20 @@ impl cosmic::Application for App {
column = column
.push(widget::text::title2(format!("{}", date)).style(style::Text::Accent));
let time = dt.format_localized("%R", locale);
// xxx It may be prudent to store the index of the selected user to avoid
// searches. This would also simplify logic elsewhere.
let time = if self
.flags
.user_datas
.binary_search_by(|probe| probe.name.cmp(&self.selected_username))
.ok()
.map(|i| self.flags.user_datas[i].clock_military_time)
.unwrap_or_default()
{
dt.format_localized("%R", locale)
} else {
dt.format_localized("%I:%M %P", locale)
};
column = column.push(
widget::text(format!("{}", time))
.size(112.0)