From bf42cf179925d2cfe03fcf3d1d2c6856be4e320f Mon Sep 17 00:00:00 2001 From: "s0wlz (Matthias Puchstein)" Date: Fri, 27 Feb 2026 12:13:23 +0100 Subject: [PATCH] hardened instant to epoch ms translation in the backend to support instants from before the app boot (future proofing for importing long running countdowns) --- src-tauri/src/app_state.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src-tauri/src/app_state.rs b/src-tauri/src/app_state.rs index 3673ad5..2c21292 100644 --- a/src-tauri/src/app_state.rs +++ b/src-tauri/src/app_state.rs @@ -17,9 +17,11 @@ impl ClockAnchor { } pub fn instant_to_epoch_ms(&self, instant: tokio::time::Instant) -> u128 { - match instant.checked_duration_since(self.boot_instant) { - Some(duration) => duration.as_millis() + self.boot_epoch_ms, - None => return 0, + if let Some(delta) = instant.checked_duration_since(self.boot_instant) { + self.boot_epoch_ms + delta.as_millis() + } else { + let delta = self.boot_instant.duration_since(instant).as_millis(); + self.boot_epoch_ms.saturating_sub(delta) } } }