From 4a1bbafb291bc54001e1b10fff501ec4b41f6606 Mon Sep 17 00:00:00 2001 From: skyline75489 Date: Wed, 14 Apr 2021 20:37:16 +0800 Subject: [PATCH] Add support for querying timezone on Android --- src/output/table.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/output/table.rs b/src/output/table.rs index fbe716cc..aa78c954 100644 --- a/src/output/table.rs +++ b/src/output/table.rs @@ -316,7 +316,15 @@ fn determine_time_zone() -> TZResult { } }) } else { - TimeZone::from_file("/etc/localtime") + if env::consts::OS == "android" { + use std::process::Command; + let mut get_time_zone = Command::new("getprop"); + get_time_zone.arg("persist.sys.timezone"); + let output = get_time_zone.output().expect("fail to get time zone"); + return CompiledData::parse(output.stdout); + } + + return TimeZone::from_file("/etc/localtime") } }