From 8ca66c5c90a76049ab62861ca8b838a83a75e8f7 Mon Sep 17 00:00:00 2001 From: TheRenegadeDev Date: Fri, 16 Oct 2026 20:42:20 -0500 Subject: [PATCH] Use the platform clock for UI timing on the web (#1026) --- crates/ui-egui/src/lib.rs | 11 +---------- crates/ui-egui/tests/ui_clock.rs | 10 ++++++++++ docs/ui-parity.md | 3 ++- 3 files changed, 13 insertions(+), 11 deletions(-) create mode 100644 crates/ui-egui/tests/ui_clock.rs diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index f96cdac3c..72a2a5d8f 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -1243,17 +1243,8 @@ pub fn clean_error(e: &str) -> String { e.to_string() } -#[allow(clippy::disallowed_methods)] // the clock is read only off wasm pub fn now_ms() -> f64 { - #[cfg(not(target_arch = "wasm32"))] - { - use std::time::{SystemTime, UNIX_EPOCH}; - SystemTime::now().duration_since(UNIX_EPOCH).map(|d| d.as_secs_f64() * 1000.0).unwrap_or(0.0) - } - #[cfg(target_arch = "wasm32")] - { - 0.0 - } + gridcraft_engine::core::date::unix_now_ms().unwrap_or(0.0) } pub fn cell(r: u32, c: u32) -> CellRef { diff --git a/crates/ui-egui/tests/ui_clock.rs b/crates/ui-egui/tests/ui_clock.rs new file mode 100644 index 000000000..6eb0dcc00 --- /dev/null +++ b/crates/ui-egui/tests/ui_clock.rs @@ -0,0 +1,10 @@ +use gridcraft_engine::core::date::unix_now_ms; + +#[test] +fn ui_clock_returns_current_unix_milliseconds() { + let before = unix_now_ms().unwrap(); + let now = gridcraft_ui_egui::now_ms(); + let after = unix_now_ms().unwrap(); + assert!(now.is_finite() && now > 0.0); + assert!((before.min(after)..=before.max(after)).contains(&now)); +} diff --git a/docs/ui-parity.md b/docs/ui-parity.md index 22e221e69..cb139e3d2 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -1,6 +1,6 @@ # UI parity -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-13 · **Change:** minor (horizontal scrollbar in the sheet tab bar, #840) · **Target:** Microsoft Excel (Microsoft 365), Excel for Mac 16.113.4 +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-16 · **Change:** minor (shared UI clock uses the browser-aware platform clock, #1026) · **Target:** Microsoft Excel (Microsoft 365), Excel for Mac 16.113.4 Interaction, controls and feel, against Excel. Part of [target-app-parity.md](target-app-parity.md). **UI/UX fidelity: ~55% ready, 50–80 h** (estimated). Ribbon command coverage is measured @@ -161,6 +161,7 @@ scrollbar bugs 2–4 · pixel/feel pass against observed Excel 7–12. | Date | Change | Summary | |---|---|---| +| 2026-10-16 | minor | The shared UI clock delegates to the core Unix-millisecond clock, which reads Date.now() on wasm, instead of returning zero there (#1026). Native clock contract tested; browser timing remains unverified | | 2026-10-12 | minor | The File view's recent list tells when each workbook was last changed, read off the UI thread | | 2026-10-13 | minor | Horizontal scrollbar in the sheet tab bar: drag, track click pages, frozen columns excluded from the page (#840) | | 2026-10-12 | minor | Ctrl+wheel zoom steps along a ladder of percentages about 20% apart that never skips 100%, gliding to each step with animations on, so a notch out undoes a notch in (it drifted: 100 → 122 → 101); Excel steps 15 points, see decisions.md |