Skip to content

Commit

Permalink
Fix deprecations for chrono
Browse files Browse the repository at this point in the history
  • Loading branch information
chmp committed Jan 6, 2024
1 parent 18fdab9 commit 534d929
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions serde_arrow/src/internal/deserialization/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1664,9 +1664,9 @@ impl Instruction for EmitDate64NaiveStr {
i64::from_ne_bytes(buffers.u64[self.buffer][positions[self.position]].to_ne_bytes());
positions[self.position] += 1;

// TODO: update with chrono 0.5
#[allow(deprecated)]
let val = NaiveDateTime::from_timestamp(val / 1000, (val % 1000) as u32 * 100_000);
let Some(val) = NaiveDateTime::from_timestamp_opt(val / 1000, (val % 1000) as u32 * 100_000) else {
fail!("Unsupported timestamp value: {val}");
};

// NOTE: chrono documents that Debug, not Display, can be parsed
Ok((self.next, Some(format!("{:?}", val).into())))
Expand All @@ -1690,9 +1690,9 @@ impl Instruction for EmitDate64UtcStr {
i64::from_ne_bytes(buffers.u64[self.buffer][positions[self.position]].to_ne_bytes());
positions[self.position] += 1;

// TODO: update with chrono 0.5
#[allow(deprecated)]
let val = Utc.timestamp(val / 1000, (val % 1000) as u32 * 100_000);
let Some(val) = Utc.timestamp_opt(val / 1000, (val % 1000) as u32 * 100_000).earliest() else {
fail!("Unsupported timestamp value: {val}");
};

// NOTE: chrono documents that Debug, not Display, can be parsed
Ok((self.next, Some(format!("{:?}", val).into())))
Expand Down

0 comments on commit 534d929

Please sign in to comment.