Skip to content

Commit 99b4fc0

Browse files
committed
chore(cubestore): Upgrade DF 46: Avoid deprecated NaiveDateTime::from_timestamp_opt, from_ymd, and_hms, DateTime::from_utc
1 parent caf8ef5 commit 99b4fc0

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

rust/cubestore/cubestore/src/cachestore/compaction.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ impl MetaStoreCacheCompactionFilter {
103103
return CompactionDecision::Keep;
104104
}
105105

106-
match chrono::NaiveDateTime::from_timestamp_opt(expire.as_i64(), 0) {
106+
match DateTime::from_timestamp(expire.as_i64(), 0) {
107107
Some(expire) => {
108-
if DateTime::<Utc>::from_utc(expire, Utc) <= self.current {
108+
if expire <= self.current {
109109
self.removed += 1;
110110

111111
CompactionDecision::Remove

rust/cubestore/cubestore/src/metastore/rocks_store.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ pub enum RocksSecondaryIndexValueVersion {
193193
pub type PackedDateTime = u32;
194194

195195
fn base_date_epoch() -> NaiveDateTime {
196-
NaiveDate::from_ymd(2022, 1, 1).and_hms(0, 0, 0)
196+
NaiveDate::from_ymd_opt(2022, 1, 1).unwrap().and_hms_opt(0, 0, 0).unwrap()
197197
}
198198

199199
pub trait RocksSecondaryIndexValueVersionEncoder {
@@ -210,7 +210,7 @@ impl RocksSecondaryIndexValueVersionDecoder for u32 {
210210
return Ok(None);
211211
}
212212

213-
let timestamp = DateTime::<Utc>::from_utc(base_date_epoch(), Utc)
213+
let timestamp = DateTime::<Utc>::from_naive_utc_and_offset(base_date_epoch(), Utc)
214214
+ chrono::Duration::seconds(self as i64);
215215

216216
Ok(Some(timestamp))
@@ -268,7 +268,7 @@ impl<'a> RocksSecondaryIndexValue<'a> {
268268
let expire = if expire_timestamp == 0 {
269269
None
270270
} else {
271-
Some(DateTime::<Utc>::from_utc(
271+
Some(DateTime::<Utc>::from_naive_utc_and_offset(
272272
NaiveDateTime::from_timestamp(expire_timestamp, 0),
273273
Utc,
274274
))

0 commit comments

Comments
 (0)