aboutsummaryrefslogtreecommitdiffstats
path: root/desktop/island/calendar/test_cal.js
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-11-13 09:17:23 +0100
committerDanilo M. <danix@danix.xyz>2026-11-13 09:17:23 +0100
commit9c47ad7c10aa5a04de738a5d41acc01cc0e5e059 (patch)
tree98ad93b89243f776aab782e35419a2ad7b8ee736 /desktop/island/calendar/test_cal.js
parentfda4e7847bb5dc985404269c81400eead52b0181 (diff)
downloadquickshell-9c47ad7c10aa5a04de738a5d41acc01cc0e5e059.tar.gz
quickshell-9c47ad7c10aa5a04de738a5d41acc01cc0e5e059.zip
feat(calendar): click-to-pick event times, loose time typing
The month grid was already the editor's date picker, but times could only be typed or wheeled. While a time field has focus the month now gives way to an hour grid and a :00/:15/:30/:45 row: an hour keeps the minutes, a minute moves on from start to end, then out of the fields. The picker replaces the grid rather than growing the editor, because the island's layer surface is a fixed 480px and the editor nearly fills it. The field keeps focus throughout, so typing and the wheel still work. Typed times are normalised: "9.30", "9:30", "930", "9" and "14h15" become HH:MM on leaving the field and again in toPayload, instead of failing with "Times are HH:MM". Impossible values still fail, unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'desktop/island/calendar/test_cal.js')
-rw-r--r--desktop/island/calendar/test_cal.js10
1 files changed, 8 insertions, 2 deletions
diff --git a/desktop/island/calendar/test_cal.js b/desktop/island/calendar/test_cal.js
index 9d0d147..de3d1c7 100644
--- a/desktop/island/calendar/test_cal.js
+++ b/desktop/island/calendar/test_cal.js
@@ -17,7 +17,7 @@ const assert = require("assert");
const src = fs.readFileSync(__dirname + "/Cal.js", "utf8").replace(/^\.pragma library$/m, "");
const C = new Function(src + "\nreturn { pad, addDays, today, daysBetween, monthCells, shiftMonth," +
- " lastDay, onDay, dayEvents, dots, timeLabel, validTime, stepTime, newDraft, fromEvent, pick," +
+ " lastDay, onDay, dayEvents, dots, timeLabel, validTime, normTime, stepTime, newDraft, fromEvent, pick," +
" toPayload };")();
// Dates are plain YYYY-MM-DD strings, arithmetic in UTC so DST never moves a day.
@@ -76,6 +76,11 @@ assert.strictEqual(C.stepTime("14:30", 15), "14:45");
assert.strictEqual(C.stepTime("23:50", 15), "00:05");
assert.strictEqual(C.stepTime("00:05", -15), "23:50");
assert.strictEqual(C.stepTime("bad", 15), "bad");
+assert.strictEqual(C.stepTime("9.30", 15), "09:45");
+for (const [i, o] of [["9.30", "09:30"], ["9:30", "09:30"], ["930", "09:30"], ["1230", "12:30"],
+ ["9", "09:00"], [" 14h15 ", "14:15"], ["09:05", "09:05"],
+ ["24.00", "24.00"], ["9.7", "9.7"], ["ab", "ab"], ["", ""]])
+ assert.strictEqual(C.normTime(i), o, i);
// A new event: the next whole hour, one hour long, alarm 1h.
const d = C.newDraft("2026-10-20", new Date(2026, 9, 13, 9, 20), "home");
@@ -111,7 +116,8 @@ assert.strictEqual(p3.endDay, "2026-10-16");
// To calctl's JSON.
assert.strictEqual(C.toPayload(Object.assign({}, d, { title: " " })).error, "Title is empty");
-assert.strictEqual(C.toPayload(Object.assign({}, d, { title: "x", startTime: "9:00" })).error, "Times are HH:MM");
+assert.strictEqual(C.toPayload(Object.assign({}, d, { title: "x", startTime: "9:00" })).payload.start.slice(11), "09:00");
+assert.strictEqual(C.toPayload(Object.assign({}, d, { title: "x", startTime: "25:00" })).error, "Times are HH:MM");
assert.strictEqual(C.toPayload(Object.assign({}, d, { title: "x", endTime: "09:00" })).error, "End is before start");
assert.strictEqual(C.toPayload(Object.assign({}, d, { title: "x", repeat: "weekly", until: "2026-10-01" })).error,
"Until is before the start");