Skip to content

Commit

Permalink
build(deps): bump chrono and replace deprecated calls (#54)
Browse files Browse the repository at this point in the history
* build(deps): update chrono and replace deprecated fn calls
  • Loading branch information
lklimek authored Mar 8, 2024
1 parent 784a0c5 commit c5ece7b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
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

0 comments on commit c5ece7b

Please sign in to comment.