From 62ac5aa029a38029a8b21e91e17419ce69a4394d Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Mon, 26 Jan 2026 12:28:54 -0800 Subject: [PATCH] wstd::time::SystemTime can be converted to std::time::SystemTime --- src/time/mod.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/time/mod.rs b/src/time/mod.rs index ff99832..db0e1b3 100644 --- a/src/time/mod.rs +++ b/src/time/mod.rs @@ -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); @@ -33,6 +34,14 @@ impl SystemTime { } } +impl From 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 }