Use local time instead of a default TZ

This commit is contained in:
Wojciech Kozlowski 2018-12-26 15:10:58 +05:30
parent 1da8fdb0a3
commit 4408b3b54b
2 changed files with 6 additions and 4 deletions

View File

@ -12,8 +12,5 @@ pub const BATT_PATH: &'static str = "/sys/class/power_supply";
/// Batteries to display. /// Batteries to display.
pub const BATTS: [&'static str; 2] = ["BAT0", "BAT1"]; pub const BATTS: [&'static str; 2] = ["BAT0", "BAT1"];
/// Default Time zone.
pub const TZ_DEF: &str = "Europe/Berlin";
/// Additional time zones to display (short name, full name). /// Additional time zones to display (short name, full name).
pub const TZS: [(char, &'static str); 2] = [('A', "America/Buenos_Aires"), ('U', "UTC")]; pub const TZS: [(char, &'static str); 2] = [('A', "America/Buenos_Aires"), ('U', "UTC")];

View File

@ -152,7 +152,7 @@ pub fn get_times() -> String {
tz_strs.push(format!("{}:{}", tz.0, get_tz_time(tz.1, "%H:%M"))); tz_strs.push(format!("{}:{}", tz.0, get_tz_time(tz.1, "%H:%M")));
} }
tz_strs.push(get_tz_time(TZ_DEF, "KW %W %a %d %b %H:%M %Z %Y")); tz_strs.push(get_local_time("KW %W %a %d %b %H:%M %Z %Y"));
tz_strs.join(" ") tz_strs.join(" ")
} }
@ -167,3 +167,8 @@ fn get_tz_time(tz_name: &str, fmt: &str) -> String {
Err(_) => return format!(""), Err(_) => return format!(""),
} }
} }
/// Get the local time.
fn get_local_time(fmt: &str) -> String {
format!("{}", Local::now().format(fmt))
}