From de9dc73fde6fca607fa7f9de2ce75abee860c1d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Raimund=20Schl=C3=BC=C3=9Fler?= Date: Mon, 5 Aug 2024 18:07:41 +0200 Subject: [PATCH] fix: correctly set allday and keep timezone MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Raimund Schlüßler --- src/models/task.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/models/task.js b/src/models/task.js index 4ab0654ce..8ec2bacde 100644 --- a/src/models/task.js +++ b/src/models/task.js @@ -483,9 +483,9 @@ export default class Task { } else { this.vtodo.removeProperty('dtstart') } + this._start = start + this._startMoment = moment(start, 'YYYYMMDDTHHmmssZ') this.updateLastModified() - this._start = this.vtodo.getFirstPropertyValue('dtstart') - this._startMoment = moment(this._start, 'YYYYMMDDTHHmmssZ') // Check all day setting const d = this._due || this._start this._allDay = d !== null && d.isDate @@ -509,9 +509,9 @@ export default class Task { } else { this.vtodo.removeProperty('due') } + this._due = due + this._dueMoment = moment(due, 'YYYYMMDDTHHmmssZ') this.updateLastModified() - this._due = this.vtodo.getFirstPropertyValue('due') - this._dueMoment = moment(this._due, 'YYYYMMDDTHHmmssZ') // Check all day setting const d = this._due || this._start this._allDay = d !== null && d.isDate @@ -531,9 +531,7 @@ export default class Task { start.isDate = allDay if (!allDay) { // If we converted to datetime, we set the hour to zero in the current timezone. - const startJs = start.toJSDate() - startJs.setHours(0) - this.setStart(ICAL.Time.fromJSDate(startJs, true)) + this.setStart(ICAL.Time.fromJSDate(moment(start, 'YYYYMMDDTHHmmssZ').toDate(), true)) } else { this.setStart(ICAL.Time.fromDateString(this._startMoment.format('YYYY-MM-DD'))) } @@ -543,9 +541,7 @@ export default class Task { due.isDate = allDay if (!allDay) { // If we converted to datetime, we set the hour to zero in the current timezone. - const dueJs = due.toJSDate() - dueJs.setHours(0) - this.setDue(ICAL.Time.fromJSDate(dueJs, true)) + this.setDue(ICAL.Time.fromJSDate(moment(due, 'YYYYMMDDTHHmmssZ').toDate(), true)) } else { this.setDue(ICAL.Time.fromDateString(this._dueMoment.format('YYYY-MM-DD'))) }