Skip to content

Commit

Permalink
fix: correctly handle timezone of completed, created and modified d ate
Browse files Browse the repository at this point in the history
Signed-off-by: Raimund Schlüßler <raimund.schluessler@mailbox.org>
  • Loading branch information
raimund-schluessler committed Aug 5, 2024
1 parent bc0e2bf commit 7464bca
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/models/task.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,13 +311,14 @@ export default class Task {
const now = ICAL.Time.fromJSDate(new Date(), true)
this.vtodo.updatePropertyWithValue('completed', now)
this._completedDate = now
this._completedDateMoment = moment(now, 'YYYYMMDDTHHmmssZ')
} else {
this.vtodo.removeProperty('completed')
this._completedDate = null
this._completedDateMoment = moment(null)
}
this.updateLastModified()
this._completed = completed
this._completedDateMoment = moment(this._completedDate, 'YYYYMMDDTHHmmssZ')
this.updateLastModified()
}

get completedDate() {
Expand Down Expand Up @@ -630,7 +631,7 @@ export default class Task {
this.vtodo.updatePropertyWithValue('last-modified', now)
this.vtodo.updatePropertyWithValue('dtstamp', now)
this._modified = now
this._modifiedMoment = moment(this._modified, 'YYYYMMDDTHHmmssZ')
this._modifiedMoment = moment(now, 'YYYYMMDDTHHmmssZ')
}

get modified() {
Expand All @@ -651,13 +652,13 @@ export default class Task {

set created(createdDate) {
this.vtodo.updatePropertyWithValue('created', createdDate)
this.updateLastModified()
this._created = this.vtodo.getFirstPropertyValue('created')
this._createdMoment = moment(this._created, 'YYYYMMDDTHHmmssZ')
this._created = createdDate
this._createdMoment = moment(createdDate, 'YYYYMMDDTHHmmssZ')
// Update the sortorder if necessary
if (this.vtodo.getFirstPropertyValue('x-apple-sort-order') === null) {
this._sortOrder = this.getSortOrder()
}
this.updateLastModified()
}

get class() {
Expand Down

0 comments on commit 7464bca

Please sign in to comment.