aboutsummaryrefslogtreecommitdiffstats
path: root/desktop/island/calendar/test_cal.js
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-11-13 09:35:54 +0100
committerDanilo M. <danix@danix.xyz>2026-11-13 09:35:54 +0100
commitbfdc3ce1e1be950dc810d19490d0b0a8ccaea3e8 (patch)
treebe3223e1cd0691c1d45977c9dd0aad2be0274914 /desktop/island/calendar/test_cal.js
parent9c47ad7c10aa5a04de738a5d41acc01cc0e5e059 (diff)
downloadquickshell-bfdc3ce1e1be950dc810d19490d0b0a8ccaea3e8.tar.gz
quickshell-bfdc3ce1e1be950dc810d19490d0b0a8ccaea3e8.zip
feat(calendar): end time follows the start, default length setting
Moving an event's start now moves its end by the island's default event length, whether the start is typed, wheeled or picked, rolling into the next day past midnight. A multi-day timed event keeps its end, since snapping it to the start's day would drop the other days. Typing follows on every edit that normalises to a valid time, so Save without leaving the field still sees the moved end. A new event gets the same length. The length lives in Prefs as island.eventMinutes (5 to 1440, default 60) and is set on a new Island bar group in the settings window, which the island's other settings will join. 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.js13
1 files changed, 12 insertions, 1 deletions
diff --git a/desktop/island/calendar/test_cal.js b/desktop/island/calendar/test_cal.js
index de3d1c7..853cbb6 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, normTime, stepTime, newDraft, fromEvent, pick," +
+ " lastDay, onDay, dayEvents, dots, timeLabel, validTime, normTime, stepTime, newDraft, withStart, fromEvent, pick," +
" toPayload };")();
// Dates are plain YYYY-MM-DD strings, arithmetic in UTC so DST never moves a day.
@@ -91,6 +91,17 @@ assert.strictEqual(d.alarm, "1h");
assert.strictEqual(d.calendar, "home");
assert.strictEqual(d.source, "");
assert.strictEqual(C.newDraft("2026-10-20", new Date(2026, 9, 13, 23, 10), "home").startTime, "22:00");
+assert.strictEqual(C.newDraft("2026-10-20", new Date(2026, 9, 13, 9, 20), "home", 90).endTime, "11:30");
+
+// The end follows the start, by the default length, past midnight too.
+const w = C.withStart(d, "23:30", 60);
+assert.strictEqual(w.startTime, "23:30");
+assert.strictEqual(w.endTime, "00:30");
+assert.strictEqual(w.endDay, "2026-10-21");
+assert.strictEqual(C.withStart(d, "14:00", 45).endTime, "14:45");
+assert.strictEqual(C.withStart(d, "9.3", 60).endTime, "11:00");
+const multi = Object.assign({}, d, { endDay: "2026-10-22", endTime: "18:00" });
+assert.strictEqual(C.withStart(multi, "08:00", 60).endTime, "18:00");
// From calctl's JSON.
const fe = C.fromEvent({ uid: "u", calendar: "home", title: "Trip", allDay: true, start: "2026-10-14",