Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/time/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ use crate::{
};

/// A measurement of the system clock, useful for talking to external entities
/// like the file system or other processes.
/// like the file system or other processes. May be converted losslessly to a
/// more useful `std::time::SystemTime` to provide more methods.
#[derive(Debug, Clone, Copy)]
#[allow(dead_code)]
pub struct SystemTime(wall_clock::Datetime);
Expand All @@ -33,6 +34,14 @@ impl SystemTime {
}
}

impl From<SystemTime> for std::time::SystemTime {
fn from(st: SystemTime) -> Self {
std::time::SystemTime::UNIX_EPOCH
+ std::time::Duration::from_secs(st.0.seconds)
+ std::time::Duration::from_nanos(st.0.nanoseconds.into())
}
}

/// An async iterator representing notifications at fixed interval.
pub fn interval(duration: Duration) -> Interval {
Interval { duration }
Expand Down