summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarey Higuera <karey.higuera@gmail.com>2020-08-26 18:19:49 -0500
committerKarey Higuera <karey.higuera@gmail.com>2020-08-26 19:31:48 -0400
commite8d69fc5e8ada7d62551d58974c7cf594d357337 (patch)
treec2df06121b693ab8a30fb16dbe43895ea829ecda
parent78ba0b8973cbfbb48b85b8beae6f7de412064d11 (diff)
Update determine_time_zone function to check TZ
Instead of defaulting immediately to /etc/filename for the timezone, we can first check whether the TZ environment variable is set. If so, we can pull the corresponding timezone file from /usr/share/zoneinfo. Closes #453.
-rw-r--r--src/output/table.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/output/table.rs b/src/output/table.rs
index 90fb236..4392401 100644
--- a/src/output/table.rs
+++ b/src/output/table.rs
@@ -1,4 +1,5 @@
use std::cmp::max;
+use std::env;
use std::fmt;
use std::ops::Deref;
use std::sync::{Mutex, MutexGuard};
@@ -286,7 +287,12 @@ impl Environment {
}
fn determine_time_zone() -> TZResult<TimeZone> {
- TimeZone::from_file("/etc/localtime")
+ let tz = env::var("TZ");
+ if tz.is_err() {
+ return TimeZone::from_file("/etc/localtime");
+ } else {
+ return TimeZone::from_file(format!("/usr/share/zoneinfo/{}", tz.unwrap()));
+ }
}