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

build(deps): bump chrono and replace deprecated calls #54

Merged
merged 5 commits into from
Mar 8, 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
2 changes: 1 addition & 1 deletion proto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ time = { version = "0.3", default-features = false, features = [
"parsing",
] }
flex-error = { version = "0.4.4", default-features = false }
chrono = { version = "0.4.24", default-features = false }
chrono = { version = "0.4.35", default-features = false }
derive_more = { version = "0.99.17" }


Expand Down
8 changes: 5 additions & 3 deletions proto/src/serializers/timestamp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ pub trait ToMilis {
impl ToMilis for Timestamp {
/// Convert protobuf timestamp into miliseconds since epoch
fn to_milis(&self) -> u64 {
chrono::NaiveDateTime::from_timestamp_opt(self.seconds, self.nanos as u32)
chrono::DateTime::from_timestamp(self.seconds, self.nanos as u32)
.unwrap()
.to_utc()
.timestamp_millis()
.try_into()
.expect("timestamp value out of u64 range")
Expand All @@ -75,12 +76,13 @@ impl FromMilis for Timestamp {
///
/// Panics when `millis` don't fit `i64` type
fn from_milis(millis: u64) -> Self {
let dt = chrono::NaiveDateTime::from_timestamp_millis(
let dt = chrono::DateTime::from_timestamp_millis(
millis
.try_into()
.expect("milliseconds timestamp out of i64 range"),
)
.expect("cannot parse timestamp");
.expect("cannot parse timestamp")
.to_utc();

Self {
nanos: dt.timestamp_subsec_nanos() as i32,
Expand Down
Loading