From 9bc29235862280563699f8fd9e35b66342bb2948 Mon Sep 17 00:00:00 2001 From: cv <34649812+cpvalente@users.noreply.github.com> Date: Sun, 31 Oct 2021 13:38:28 +0100 Subject: [PATCH] fix: handle midnight fixed issue where roll mode wouldnt recognise a end time lower than start time (go through midnight) --- server/src/classes/EventTimer.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/server/src/classes/EventTimer.js b/server/src/classes/EventTimer.js index f93599cc1..64ba0c383 100644 --- a/server/src/classes/EventTimer.js +++ b/server/src/classes/EventTimer.js @@ -973,7 +973,14 @@ export class EventTimer extends Timer { // loop through events, look for where we should be for (const [index, e] of this._eventlist.entries()) { if (!foundNow) { - if (e.timeStart <= now && now < e.timeEnd) { + let normalEnd = e.timeEnd; + + // handle midnight + if (normalEnd < e.timeStart) { + normalEnd += this.DAYMS; + } + + if (e.timeStart <= now && now < normalEnd) { // set flag foundNow = true; @@ -982,9 +989,9 @@ export class EventTimer extends Timer { this._secondaryTarget = null; this._startedAt = e.timeStart; - this._finishAt = e.timeEnd; - this.duration = e.timeEnd - e.timeStart; - this.current = e.timeEnd - now; + this._finishAt = normalEnd; + this.duration = normalEnd - e.timeStart; + this.current = normalEnd - now; // set selection this.selectedEventId = e.id;