summaryrefslogtreecommitdiffstats
path: root/src/output
diff options
context:
space:
mode:
authorBen S <ogham@bsago.me>2016-02-10 19:02:20 +0000
committerBen S <ogham@bsago.me>2016-02-10 19:02:20 +0000
commit7f480ab06bd6337f898e28cca42a3cc454048e61 (patch)
tree9bd12ce1beff538a79a872cba6a1e53d18ab88d5 /src/output
parent8cadfa00492f789eb733538908626b41931456a1 (diff)
Improve system time zone detection
Diffstat (limited to 'src/output')
-rw-r--r--src/output/details.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/output/details.rs b/src/output/details.rs
index a6ff7da..cea6bc4 100644
--- a/src/output/details.rs
+++ b/src/output/details.rs
@@ -82,6 +82,7 @@ use ansi_term::Style;
use datetime::fmt::DateFormat;
use datetime::{LocalDateTime, DatePiece};
use datetime::TimeZone;
+use zoneinfo_compiled::CompiledData;
use zoneinfo_data::ZoneinfoData;
use locale;
@@ -168,12 +169,21 @@ impl Default for Environment<UsersCache> {
current_year: LocalDateTime::now().year(),
numeric: locale::Numeric::load_user_locale().unwrap_or_else(|_| locale::Numeric::english()),
time: locale::Time::load_user_locale().unwrap_or_else(|_| locale::Time::english()),
- tz: TimeZone::system().expect("Unable to determine time zone"),
+ tz: determine_time_zone().expect("Unable to determine time zone"),
users: Mutex::new(UsersCache::new()),
}
}
}
+fn determine_time_zone() -> Result<TimeZone> {
+ if let Some(system_zone) = TimeZone::system() {
+ Ok(system_zone)
+ }
+ else {
+ TimeZone::from_file("/etc/localtime")
+ }
+}
+
impl Details {
/// Print the details of the given vector of files -- all of which will