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

Deal with chrono deprecations #951

Merged
merged 2 commits into from
Mar 7, 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
145 changes: 101 additions & 44 deletions Cargo.lock.msrv

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion scylla-cql/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ thiserror = "1.0"
num-bigint-03 = { package = "num-bigint", version = "0.3", optional = true }
num-bigint-04 = { package = "num-bigint", version = "0.4", optional = true }
bigdecimal-04 = { package = "bigdecimal", version = "0.4", optional = true }
chrono = { version = "0.4.27", default-features = false, optional = true }
chrono = { version = "0.4.32", default-features = false, optional = true }
lz4_flex = { version = "0.11.1" }
async-trait = "0.1.57"
serde = { version = "1.0", features = ["derive"], optional = true }
Expand Down
4 changes: 2 additions & 2 deletions scylla-cql/src/frame/response/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1580,10 +1580,10 @@ mod tests {
#[cfg(feature = "chrono")]
#[test]
fn test_datetime_from_cql() {
use chrono::{NaiveDate, NaiveDateTime, NaiveTime};
use chrono::{DateTime, NaiveDate, NaiveDateTime, NaiveTime};

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

Expand Down
2 changes: 1 addition & 1 deletion scylla-cql/src/frame/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ impl TryInto<NaiveDate> for CqlDate {

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

NaiveDate::from_yo_opt(1970, 1)
.unwrap()
Expand Down
Loading
Loading