Misc · Time: Lap turns Reset, laps and tickers tested

The stopwatch's second button reads Lap while running and Reset once
paused, on one focus handle, and Reset hands focus to Start, so no
press leaves focus stranded. Lap rows carry selectors; tests hold
their order and times, count the tickers' wakes, and a WorldClock
without places fails.
This commit is contained in:
ZacharyZhang-NY committed 2026-09-28 00:21:23 -04:00
1 parent 45ae161c18
commit b586300f0e
4 files changed
+127 -42

No files matched your search

+15 -6
View File
@@ -187,7 +187,7 @@ impl RenderOnce for Clock {
}
}
/// Places and their zones, a row each: a small face, the place, how its day and hour stand against home, and its time. Home is the system zone unless told; it ticks each second, or shows the owner's moment.
/// Places and their zones, a row each: a small face, the place, how its day and hour stand against home, and its time; fails without places. Home is the system zone unless told; it ticks each second, or shows the owner's moment.
#[derive(IntoElement)]
pub struct WorldClock {
id: ElementId,
@@ -201,12 +201,15 @@ impl WorldClock {
id: impl Into<ElementId>,
places: impl IntoIterator<Item = (impl Into<SharedString>, TimeZone)>,
) -> Self {
let id = id.into();
let places: Vec<_> = places
.into_iter()
.map(|(name, zone)| (name.into(), zone))
.collect();
assert!(!places.is_empty(), "world clock {id:?} has no places");
Self {
id: id.into(),
places: places
.into_iter()
.map(|(name, zone)| (name.into(), zone))
.collect(),
id,
places,
home: None,
now: None,
}
@@ -291,6 +294,12 @@ mod tests {
assert_eq!(second, 0.25);
}
#[test]
#[should_panic(expected = "has no places")]
fn a_world_clock_without_places_fails() {
super::WorldClock::new("world", Vec::<(&str, TimeZone)>::new());
}
#[test]
fn a_zone_stands_against_home_by_day_and_offset() {
let now: Timestamp = "2026-09-28T03:00:00Z".parse().expect("a moment");