Skip to content

Commit

Permalink
Update epoch.rs to use "instant" crate
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasantony committed Dec 10, 2023
1 parent ccc2398 commit 1e3ea72
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/epoch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ use crate::leap_seconds_file::LeapSecondsFile;
use serde_derive::{Deserialize, Serialize};

use core::str::FromStr;
#[cfg(feature = "std")]
use std::time::SystemTime;

#[cfg(not(feature = "std"))]
use num_traits::{Euclid, Float};
Expand Down Expand Up @@ -2827,12 +2825,11 @@ impl Epoch {
impl Epoch {
/// Initializes a new Epoch from `now`.
/// WARNING: This assumes that the system time returns the time in UTC (which is the case on Linux)
/// Uses [`std::time::SystemTime::now`](https://doc.rust-lang.org/std/time/struct.SystemTime.html#method.now) under the hood
/// Uses [`std::time::SystemTime::now`](https://doc.rust-lang.org/std/time/struct.SystemTime.html#method.now)
/// or javascript interop under the hood
pub fn now() -> Result<Self, Errors> {
match SystemTime::now().duration_since(SystemTime::UNIX_EPOCH) {
Ok(std_duration) => Ok(Self::from_unix_seconds(std_duration.as_secs_f64())),
Err(_) => Err(Errors::SystemTimeError),
}
let duration = crate::system_time::duration_since_unix_epoch()?;
Ok(Self::from_duration(duration, TimeScale::UTC))
}
}

Expand Down

0 comments on commit 1e3ea72

Please sign in to comment.