Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for querying timezone on Android #846

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/output/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,15 @@ fn determine_time_zone() -> TZResult<TimeZone> {
}
})
} else {
TimeZone::from_file("/etc/localtime")
if env::consts::OS == "android" {
Copy link
Collaborator

@ariasuni ariasuni May 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose it’s a good practice to include the “documentation” for this change.

Suggested change
if env::consts::OS == "android" {
// https://android.googlesource.com/platform/bionic/+/master/libc/tzcode/bionic.cpp
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);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CompiledData is a trait, and TimeZone is implementing this trait:

Suggested change
return CompiledData::parse(output.stdout);
return TimeZone::parse(output.stdout);

}

return TimeZone::from_file("/etc/localtime")
}
}

Expand Down