Offer AM/PM clock formats when right-clicking the bar clock (#6536)

Every preset in the right-click ring was 24-hour, so a 12-hour label was
something you had to hand-write into shell.json. Pair each locale-shaped
time preset with its AM/PM twin, and give vertical bars one stacked
variant. The ISO preset keeps its 24-hour clock, since ISO 8601 writes
time that way.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Scott Jones
2026-08-03 16:29:14 -05:00
committed by GitHub
co-authored by Claude Opus 5
parent 929eca317d
commit 72ffd58316
2 changed files with 38 additions and 2 deletions
+26 -1
View File
@@ -138,7 +138,32 @@ assertDeepEqual(calendar.clockFormatRing('', '', []), ['HH:mm'], 'clock keeps a
assertEqual(calendar.nextClockFormat(ring, ring[0]), ring[1], 'clock steps to the next format')
assertEqual(calendar.nextClockFormat(ring, ring[ring.length - 1]), ring[0], 'clock wraps the format ring')
assertEqual(calendar.nextClockFormat(ring, 'HH:mm:ss'), ring[0], 'clock starts at the top from a format outside the ring')
assertEqual(calendar.clockFormats(true)[0], 'HH\n\u2014\nmm', 'clock keeps stacked formats for vertical bars')
// Both rings, contents and order: a right click walks this list and writes
// the result back to shell.json, so an inserted preset should have to be
// acknowledged here.
assertDeepEqual(
calendar.clockFormats(false),
[
'dddd HH:mm', 'dddd h:mm AP',
'HH:mm', 'h:mm AP',
'ddd d MMM HH:mm', 'ddd d MMM h:mm AP',
"d MMMM 'W'ww yyyy",
// No twin: ISO 8601 writes time on a 24-hour clock, so an AM/PM variant
// would contradict the one thing that format is for.
'yyyy-MM-dd HH:mm'
],
'clock offers the horizontal presets in this order'
)
assertDeepEqual(
calendar.clockFormats(true),
['HH\n\u2014\nmm', 'h\n\u2014\nmm\nAP', "dd\nMMM\n'W'ww\n''yy", 'HH\nmm'],
'clock offers the stacked presets in this order'
)
assertEqual(
calendar.nextClockFormat(ring, 'dddd HH:mm'),
'dddd h:mm AP',
'clock reaches an AM/PM twin in one right click'
)
assertEqual(calendar.isoWeekLiteral(2026, 0, 5), '02', 'clock zero-pads the ISO week token')
// ---- widget wiring