diff --git a/chrono-tz/Cargo.toml b/chrono-tz/Cargo.toml index 825ca20..28e7ec4 100644 --- a/chrono-tz/Cargo.toml +++ b/chrono-tz/Cargo.toml @@ -30,7 +30,7 @@ include = [ [dependencies] arbitrary = { version = "1.2", optional = true, features = ["derive"] } -chrono = { version = "0.4.24", default-features = false } +chrono = { version = "0.4.25", default-features = false } serde = { version = "1.0.99", optional = true, default-features = false } phf = { version = "0.11", default-features = false } uncased = { version = "0.9", optional = true, default-features = false } diff --git a/chrono-tz/src/timezone_impl.rs b/chrono-tz/src/timezone_impl.rs index e6c35ee..4c1e3f4 100644 --- a/chrono-tz/src/timezone_impl.rs +++ b/chrono-tz/src/timezone_impl.rs @@ -328,7 +328,7 @@ impl TimeZone for Tz { // First search for a timespan that the local datetime falls into, then, if it exists, // check the two surrounding timespans (if they exist) to see if there is any ambiguity. fn offset_from_local_datetime(&self, local: &NaiveDateTime) -> LocalResult { - let timestamp = local.timestamp(); + let timestamp = local.and_utc().timestamp(); let timespans = self.timespans(); let index = binary_search(0, timespans.len(), |i| timespans.local_span(i).cmp(timestamp)); TzOffset::map_localresult( @@ -360,8 +360,8 @@ impl TimeZone for Tz { // Binary search for the required timespan. Any i64 is guaranteed to fall within // exactly one timespan, no matter what (so the `unwrap` is safe). - fn offset_from_utc_datetime(&self, utc: &NaiveDateTime) -> Self::Offset { - let timestamp = utc.timestamp(); + fn offset_from_utc_datetime(&self, dt: &NaiveDateTime) -> Self::Offset { + let timestamp = dt.and_utc().timestamp(); let timespans = self.timespans(); let index = binary_search(0, timespans.len(), |i| timespans.utc_span(i).cmp(timestamp)).unwrap(); diff --git a/chrono-tz/tests/check-regex-filtering/src/lib.rs b/chrono-tz/tests/check-regex-filtering/src/lib.rs index c8d169a..9db6010 100644 --- a/chrono-tz/tests/check-regex-filtering/src/lib.rs +++ b/chrono-tz/tests/check-regex-filtering/src/lib.rs @@ -19,7 +19,7 @@ mod tests { fn london_compiles() { // This line will be a compilation failure if the code generation // mistakenly excluded Europe::London. - let _london_time = London.ymd(2013, 12, 25).and_hms(14, 0, 0); + let _london_time = London.with_ymd_and_hms(2013, 12, 25, 14, 0, 0); assert_eq!("Europe/London", London.name()); // Since London is included, converting from the corresponding