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

Remove iana-time-zone dependency for clock feature. #1018

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ edition = "2018"
name = "chrono"

[features]
default = ["clock", "std", "wasmbind"]
default = ["clock", "std", "wasmbind", "iana-time-zone"]
alloc = []
libc = []
std = []
clock = ["std", "windows-sys", "iana-time-zone"]
clock = ["std", "windows-sys"]
wasmbind = ["wasm-bindgen", "js-sys"]
unstable-locales = ["pure-rust-locales", "alloc"]
__internal_bench = ["criterion"]
Expand Down
6 changes: 6 additions & 0 deletions src/offset/local/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,18 @@ const TZDB_LOCATION: &str = "/usr/share/lib/zoneinfo";
#[cfg(not(any(target_os = "android", target_os = "aix")))]
const TZDB_LOCATION: &str = "/usr/share/zoneinfo";

#[cfg(feature = "iana-time-zone")]
fn fallback_timezone() -> Option<TimeZone> {
let tz_name = iana_time_zone::get_timezone().ok()?;
let bytes = fs::read(format!("{}/{}", TZDB_LOCATION, tz_name)).ok()?;
TimeZone::from_tz_data(&bytes).ok()
}

#[cfg(not(feature = "iana-time-zone"))]
fn fallback_timezone() -> Option<TimeZone> {
None
}

impl Default for Cache {
fn default() -> Cache {
// default to UTC if no local timezone can be found
Expand Down