Merge the 12-hour clock into the Digital Clock
CI / test (push) Failing after 18s

clock-digital12 and clock-digital had become the same module (same lib/clock
code, same right-click settings), differing only in the starting format. Keep
one: the Digital Clock now starts in 12-hour mode with AM/PM, and its
"Time format" setting switches to 24-hour.

- components/clock-digital12 is gone (and from scripts/components.txt);
  lib/clock drops digital12_info/digital12_config.
- The default panel loads clock-digital.
- "clock-digital12" stays an alias (find_module, slot_of, saved panels) and is
  never listed in the module picker, even if an old .wasm is still installed.
- panel.edn gets :version 2. A version-1 panel is migrated once: the old
  12-hour clock becomes the Digital Clock with its settings (state.edn
  :module-config) moved over in 12-hour mode; a panel that had the old
  24-hour Digital Clock keeps 24-hour. The file is rewritten afterwards.
- Tests updated, plus a migration test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hgnZsS91fwCreut8FL
This commit is contained in:
Claude committed 2026-11-25 20:29:12 +00:00
1 parent 9c0a794c2d
commit c7a6c8376e
25 files changed
+207 -925

No files matched your search

+11 -9
View File
@@ -97,13 +97,15 @@ fn drain() -> Array[HostRequest] {
test "a module's own settings (module-config) are listed and set through wasmer" {
let p = load_module("clock-digital")
let items = p.config_items()
assert_eq(items.length(), 2)
assert_eq(items[0], { key: "format", label: "Time format", choices: ["24-hour", "12-hour"], value: "24-hour" })
// 12-hour by default: Time format, Show AM/PM, Show date.
assert_eq(items.length(), 3)
assert_eq(items[0], { key: "format", label: "Time format", choices: ["24-hour", "12-hour"], value: "12-hour" })
assert_eq(items[1].choices.length(), 0) // an on/off switch
assert_true(p.set_config("format", "12-hour"))
assert_false(p.set_config("format", "12-hour")) // unchanged
assert_true(p.set_config("format", "24-hour"))
assert_false(p.set_config("format", "24-hour")) // unchanged
assert_false(p.set_config("bogus", "x"))
assert_eq(p.config_items()[0].value, "12-hour")
assert_eq(p.config_items()[0].value, "24-hour")
assert_eq(p.config_items().length(), 2) // no AM/PM switch in 24-hour mode
let mut ampm = false
for op in p.render(p.pref_w, p.pref_h, test_tokens()) {
match op {
@@ -111,7 +113,7 @@ test "a module's own settings (module-config) are listed and set through wasmer"
_ => ()
}
}
assert_true(ampm)
assert_false(ampm)
p.unload()
// Modules without the export have no settings, and setting one is a no-op.
let l = load_module("layout")
@@ -287,12 +289,12 @@ test "interface explorer module toggles through the inspector capability" {
}
///|
test "moon and 12-hour clock modules render from the clock capability" {
test "moon and digital clock modules render from the clock capability" {
let m = load_module("moon-disc")
assert_true(m.render(36, 36, test_tokens()).length() > 3)
m.unload()
let c = load_module("clock-digital12")
let c = load_module("clock-digital")
let ts = texts_of(c.render(120, 36, test_tokens()))
assert_true(ts[0].has_suffix("AM") || ts[0].has_suffix("PM"))
assert_true(ts[0].has_suffix("AM") || ts[0].has_suffix("PM")) // 12-hour by default
c.unload()
}