Merge pull request #818 from PatriotRossii/feature/determine_time_zone

Update determine_time_zone according to GNU manual
This commit is contained in:
Benjamin Sago 2021-03-30 14:49:48 +01:00 committed by GitHub
commit 96e3f3d8d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -292,9 +292,20 @@ impl Environment {
fn determine_time_zone() -> TZResult<TimeZone> {
if let Ok(file) = env::var("TZ") {
TimeZone::from_file(format!("/usr/share/zoneinfo/{}", file))
TimeZone::from_file({
if file.starts_with("/") {
file
} else {
format!("/usr/share/zoneinfo/{}", {
if file.starts_with(":") {
file.replacen(":", "", 1)
} else {
file
}
else {
})
}
})
} else {
TimeZone::from_file("/etc/localtime")
}
}