fix(set): clamp hour() to 23 instead of the invalid 24

hour(n) with n >= 24 clamped n to 24, which walkTo() rejects as an invalid
hour (valid range 0-23), nulling the epoch and invalidating the object.
Clamp to 23 to match the other overflow-clamping setters (date, month).
This commit is contained in:
dualfroz committed 2026-09-04 09:43:57 +02:00
1 parent cdeb1866ab
commit d48b259893
3 files changed
+96 -1

No files matched your search

+3 -1
View File
@@ -67,8 +67,10 @@ const minutes = function (s, n, goFwd) {
const hours = function (s, n, goFwd) {
n = validate(n)
// clamp to a valid hour (0-23). Clamping to 24 produces an hour that
// walkTo() rejects, which nulls the epoch and invalidates the object.
if (n >= 24) {
n = 24
n = 23
} else if (n < 0) {
n = 0
}