From cdeb1866ab11bff550470f9e0facb6e6124af558 Mon Sep 17 00:00:00 2001 From: upstream Date: Fri, 4 Sep 2026 09:43:57 +0200 Subject: [PATCH] Upstream spencermountain/spacetime state of the touched files before 2331aa9f8f --- src/methods/set/set.js | 3 +-- test/set.test.js | 13 ------------- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/src/methods/set/set.js b/src/methods/set/set.js index b6c83c6..1c7d087 100644 --- a/src/methods/set/set.js +++ b/src/methods/set/set.js @@ -67,9 +67,8 @@ const minutes = function (s, n, goFwd) { const hours = function (s, n, goFwd) { n = validate(n) - // Clamp to 0-23: hour 24 is rejected by walkTo(), which nulls the epoch. if (n >= 24) { - n = 23 + n = 24 } else if (n < 0) { n = 0 } diff --git a/test/set.test.js b/test/set.test.js index d09a3c1..9efdcee 100644 --- a/test/set.test.js +++ b/test/set.test.js @@ -238,16 +238,3 @@ test('month()/date() setters clamp the day to the month length', (t) => { t.equal(iso(spacetime('2021-02-10').date(31)), '2021-02-28', 'date(31) in a common february clamps to the 28th') t.end() }) - -test('hour() setter clamps out-of-range hours to a valid hour', (t) => { - const s = spacetime('2021-03-14 10:00:00', 'UTC') - // an out-of-range hour must clamp to 23, not null the epoch - t.equal(s.hour(24).hour(), 23, 'hour(24) clamps to 23') - t.equal(s.hour(25).hour(), 23, 'hour(25) clamps to 23') - t.equal(s.hour(100).hour(), 23, 'hour(100) clamps to 23') - t.equal(s.hour(24).isValid(), true, 'hour(24) stays valid') - t.equal(s.hour(24).format('iso-short'), '2021-03-14', 'hour(24) keeps the same day') - // negative hours still clamp to 0 - t.equal(s.hour(-1).hour(), 0, 'hour(-1) clamps to 0') - t.end() -})