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
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()));
+ }
}
