mirror of
https://github.com/Llewellynvdm/exa.git
synced 2024-11-22 12:05:11 +00:00
Improve system time zone detection
This commit is contained in:
parent
8cadfa0049
commit
7f480ab06b
29
Cargo.lock
generated
29
Cargo.lock
generated
@ -17,6 +17,7 @@ dependencies = [
|
||||
"term_grid 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"unicode-width 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"users 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"zoneinfo_compiled 0.2.1 (git+https://github.com/rust-datetime/zoneinfo-compiled.git)",
|
||||
"zoneinfo_data 0.1.0 (git+https://github.com/rust-datetime/zoneinfo-data.git)",
|
||||
]
|
||||
|
||||
@ -39,6 +40,11 @@ name = "bitflags"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "byteorder"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "cmake"
|
||||
version = "0.1.12"
|
||||
@ -133,7 +139,7 @@ dependencies = [
|
||||
"libc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libssh2-sys 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libz-sys 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"openssl-sys 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"openssl-sys 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pkg-config 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
@ -153,7 +159,7 @@ dependencies = [
|
||||
"cmake 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libz-sys 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"openssl-sys 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"openssl-sys 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pkg-config 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -199,7 +205,7 @@ version = "0.1.30"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"rand 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -222,7 +228,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "openssl-sys"
|
||||
version = "0.7.5"
|
||||
version = "0.7.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"gdi32-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -265,7 +271,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rustc-serialize"
|
||||
version = "0.3.17"
|
||||
version = "0.3.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
@ -316,7 +322,7 @@ version = "0.2.38"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"uuid 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
@ -343,7 +349,7 @@ version = "0.1.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"rand 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -365,6 +371,15 @@ dependencies = [
|
||||
"winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zoneinfo_compiled"
|
||||
version = "0.2.1"
|
||||
source = "git+https://github.com/rust-datetime/zoneinfo-compiled.git#4ba145058702e68c322e8c822c3cf067b2b201f9"
|
||||
dependencies = [
|
||||
"byteorder 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"datetime 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zoneinfo_data"
|
||||
version = "0.1.0"
|
||||
|
@ -37,3 +37,6 @@ optional = true
|
||||
|
||||
[dependencies.zoneinfo_data]
|
||||
git = "https://github.com/rust-datetime/zoneinfo-data.git"
|
||||
|
||||
[dependencies.zoneinfo_compiled]
|
||||
git = "https://github.com/rust-datetime/zoneinfo-compiled.git"
|
@ -14,6 +14,7 @@ extern crate scoped_threadpool;
|
||||
extern crate term_grid;
|
||||
extern crate unicode_width;
|
||||
extern crate users;
|
||||
extern crate zoneinfo_compiled;
|
||||
extern crate zoneinfo_data;
|
||||
|
||||
#[cfg(feature="git")] extern crate git2;
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user