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

Apply lib.rs suggestions #162

Merged
merged 2 commits into from
Apr 5, 2024
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
3 changes: 3 additions & 0 deletions chrono-tz-build/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ rust-version = "1.60"
description = "internal build script for chrono-tz"
readme = "README.md"
license = "MIT OR Apache-2.0"
keywords = ["script", "chrono-tz", "timezone", "iana"]
categories = ["development-tools::build-utils"]
repository = "https://github.com/chronotope/chrono-tz"
documentation = "https://docs.rs/chrono-tz-build"

[features]
filter-by-regex = ["regex"]
case-insensitive = ["uncased", "phf/uncased"]
regex = ["dep:regex"]

[dependencies]
parse-zoneinfo = { version = "0.3" }
Expand Down
7 changes: 4 additions & 3 deletions chrono-tz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ edition = "2021"
rust-version = "1.60"
build = "build.rs"
description = "TimeZone implementations for chrono from the IANA database"
keywords = ["date", "time", "timezone", "zone", "calendar"]
keywords = ["date", "time", "timezone", "zone", "iana"]
categories = ["date-and-time"]
repository = "https://github.com/chronotope/chrono-tz"
documentation = "https://docs.rs/chrono-tz"
readme = "../README.md"
Expand All @@ -29,8 +30,8 @@ include = [

[dependencies]
arbitrary = { version = "1.2", optional = true, features = ["derive"] }
chrono = { version = "0.4.24", default-features = false }
serde = { version = "1", optional = true, default-features = false }
chrono = { version = "0.4.25", default-features = false }
serde = { version = "1.0.99", optional = true, default-features = false }
djc marked this conversation as resolved.
Show resolved Hide resolved
phf = { version = "0.11", default-features = false }
uncased = { version = "0.9", optional = true, default-features = false }

Expand Down
6 changes: 3 additions & 3 deletions chrono-tz/src/timezone_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Self::Offset> {
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(
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion chrono-tz/tests/check-regex-filtering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading