Skip to content

Commit

Permalink
Avoid breaking API change in public crate ofdb-entities
Browse files Browse the repository at this point in the history
  • Loading branch information
flosse committed Sep 19, 2023
1 parent dd3c17a commit e4547c3
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ofdb-entities/src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,23 @@ impl Timestamp {
Ok(Self(date_time))
}

#[deprecated]
pub fn from_secs(seconds: i64) -> Self {
Self::try_from_secs(seconds).unwrap()
}

pub fn try_from_millis(milliseconds: i64) -> Result<Self, OutOfRangeError> {
let nanos = millis_to_nanos(milliseconds);
let date_time = time::OffsetDateTime::from_unix_timestamp_nanos(nanos)
.map_err(|err| OutOfRangeError(err.to_string()))?;
Ok(Self(date_time))
}

#[deprecated]
pub fn from_millis(milliseconds: i64) -> Self {
Self::try_from_millis(milliseconds).unwrap()
}

pub fn as_secs(self) -> i64 {
self.0.unix_timestamp()
}
Expand Down

0 comments on commit e4547c3

Please sign in to comment.