Skip to content

Commit 345a134

Browse files
committed
chore(cubestore): Upgrade DF: Avoid deprecated NaiveDateTime::from_timestamp_opt, from_ymd, and_hms, DateTime::from_utc
1 parent 6dfff86 commit 345a134

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-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: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,10 @@ 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)
197+
.unwrap()
198+
.and_hms_opt(0, 0, 0)
199+
.unwrap()
197200
}
198201

199202
pub trait RocksSecondaryIndexValueVersionEncoder {
@@ -210,7 +213,7 @@ impl RocksSecondaryIndexValueVersionDecoder for u32 {
210213
return Ok(None);
211214
}
212215

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

216219
Ok(Some(timestamp))
@@ -268,7 +271,7 @@ impl<'a> RocksSecondaryIndexValue<'a> {
268271
let expire = if expire_timestamp == 0 {
269272
None
270273
} else {
271-
Some(DateTime::<Utc>::from_utc(
274+
Some(DateTime::<Utc>::from_naive_utc_and_offset(
272275
NaiveDateTime::from_timestamp(expire_timestamp, 0),
273276
Utc,
274277
))

0 commit comments

Comments
 (0)