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

Use tzdb to support Windows hosts, too #107

Merged
merged 1 commit into from
Jul 21, 2022
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ all-features = true
[dependencies]
is_debug = "1.0.1"
const_format = "0.2.22"
tz-rs = "0.6.11"
time = { version = "0.3.11", features = ["formatting", "local-offset", "parsing"] }
tzdb = { version = "0.2.7", default-features = false, features = ["local"] }

#! Optional Dependencies:

Expand Down
4 changes: 2 additions & 2 deletions src/data_time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use std::time::{SystemTime, UNIX_EPOCH};
use time::format_description::well_known::{Rfc2822, Rfc3339};
use time::UtcOffset;
use time::{format_description, OffsetDateTime};
use tz::TimeZone;

pub enum DateTime {
Local(OffsetDateTime),
Expand Down Expand Up @@ -50,7 +49,8 @@ impl DateTime {
}

pub fn local_now() -> Result<Self, Box<dyn Error>> {
let time_zone_local = TimeZone::local()?; // expensive call, should be cached
// expensive call, should be cached
let time_zone_local = tzdb::local_tz().ok_or("Could not get local timezone")?;

let duration_since_epoch = SystemTime::now().duration_since(UNIX_EPOCH)?;
let local_time_type =
Expand Down