Skip to content

Commit 44785bd

Browse files
authored
Merge pull request #951 from Lorak-mmk/fix-chrono-duration-days
Deal with chrono deprecations
2 parents da49a7d + 4057845 commit 44785bd

File tree

8 files changed

+126
-68
lines changed

8 files changed

+126
-68
lines changed

Cargo.lock.msrv

Lines changed: 101 additions & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scylla-cql/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ thiserror = "1.0"
2121
num-bigint-03 = { package = "num-bigint", version = "0.3", optional = true }
2222
num-bigint-04 = { package = "num-bigint", version = "0.4", optional = true }
2323
bigdecimal-04 = { package = "bigdecimal", version = "0.4", optional = true }
24-
chrono = { version = "0.4.27", default-features = false, optional = true }
24+
chrono = { version = "0.4.32", default-features = false, optional = true }
2525
lz4_flex = { version = "0.11.1" }
2626
async-trait = "0.1.57"
2727
serde = { version = "1.0", features = ["derive"], optional = true }

scylla-cql/src/frame/response/result.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1580,10 +1580,10 @@ mod tests {
15801580
#[cfg(feature = "chrono")]
15811581
#[test]
15821582
fn test_datetime_from_cql() {
1583-
use chrono::{NaiveDate, NaiveDateTime, NaiveTime};
1583+
use chrono::{DateTime, NaiveDate, NaiveDateTime, NaiveTime};
15841584

15851585
// 0 when converted to DateTime is 1970-01-01 0:00:00.00
1586-
let unix_epoch = NaiveDateTime::from_timestamp_opt(0, 0).unwrap().and_utc();
1586+
let unix_epoch = DateTime::from_timestamp(0, 0).unwrap();
15871587
let date = super::deser_cql_value(&ColumnType::Timestamp, &mut 0i64.to_be_bytes().as_ref())
15881588
.unwrap();
15891589

scylla-cql/src/frame/value.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ impl TryInto<NaiveDate> for CqlDate {
489489

490490
// date_days is u32 then converted to i64 then we subtract 2^31;
491491
// Max value is 2^31, min value is -2^31. Both values can safely fit in chrono::Duration, this call won't panic
492-
let duration_since_unix_epoch = chrono::Duration::days(days_since_unix_epoch);
492+
let duration_since_unix_epoch = chrono::Duration::try_days(days_since_unix_epoch).unwrap();
493493

494494
NaiveDate::from_yo_opt(1970, 1)
495495
.unwrap()

0 commit comments

Comments
 (0)