fix: handle midnight

fixed issue where roll mode wouldnt recognise a end time lower than start time (go through midnight)
This commit is contained in:
cv
2021-10-31 13:38:28 +01:00
parent 93580554bd
commit 9bc2923586
+11 -4
View File
@@ -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;