Skip to content

Commit

Permalink
deprecate as_ms_i64 and from_total_ms
Browse files Browse the repository at this point in the history
  • Loading branch information
xiangjinwu committed Mar 9, 2023
1 parent 74e26c0 commit a445d26
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/common/src/types/interval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ impl IntervalUnit {
/// If day is positive, complement the ms negative value.
/// These rules only use in interval comparison.
pub fn justify_interval(&mut self) {
let total_ms = self.total_ms();
#[expect(deprecated)]
let total_ms = self.as_ms_i64();
*self = Self {
months: 0,
days: (total_ms / DAY_MS) as i32,
Expand All @@ -94,8 +95,8 @@ impl IntervalUnit {
interval
}

#[must_use]
pub fn from_total_ms(ms: i64) -> Self {
#[deprecated]
fn from_total_ms(ms: i64) -> Self {
let mut remaining_ms = ms;
let months = remaining_ms / MONTH_MS;
remaining_ms -= months * MONTH_MS;
Expand All @@ -108,10 +109,6 @@ impl IntervalUnit {
}
}

pub fn total_ms(&self) -> i64 {
self.months as i64 * MONTH_MS + self.days as i64 * DAY_MS + self.ms
}

#[must_use]
pub fn from_ymd(year: i32, month: i32, days: i32) -> Self {
let months = year * 12 + month;
Expand Down Expand Up @@ -184,10 +181,13 @@ impl IntervalUnit {
return None;
}

#[expect(deprecated)]
let ms = self.as_ms_i64();
#[expect(deprecated)]
Some(IntervalUnit::from_total_ms((ms as f64 / rhs).round() as i64))
}

#[deprecated]
fn as_ms_i64(&self) -> i64 {
self.months as i64 * MONTH_MS + self.days as i64 * DAY_MS + self.ms
}
Expand All @@ -200,7 +200,9 @@ impl IntervalUnit {
let rhs = rhs.try_into().ok()?;
let rhs = rhs.0;

#[expect(deprecated)]
let ms = self.as_ms_i64();
#[expect(deprecated)]
Some(IntervalUnit::from_total_ms((ms as f64 * rhs).round() as i64))
}

Expand Down

0 comments on commit a445d26

Please sign in to comment.