2323 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
2424 *
2525 */
26- import dayjs from 'dayjs'
26+
27+ import moment from '@nextcloud/moment'
2728
2829import ICAL from 'ical.js'
2930import { randomUUID } from '../utils/crypto.js'
@@ -94,27 +95,27 @@ export default class Task {
9495 this . _priority = this . vtodo . getFirstPropertyValue ( 'priority' ) || 0
9596 this . _complete = this . vtodo . getFirstPropertyValue ( 'percent-complete' ) || 0
9697 this . _completedDate = this . vtodo . getFirstPropertyValue ( 'completed' )
97- this . _completedDateMoment = dayjs ( this . _completedDate , 'YYYYMMDDTHHmmssZ' )
98+ this . _completedDateMoment = moment ( this . _completedDate , 'YYYYMMDDTHHmmssZ' )
9899 this . _completed = ! ! this . _completedDate
99100 this . _status = this . vtodo . getFirstPropertyValue ( 'status' )
100101 this . _note = this . vtodo . getFirstPropertyValue ( 'description' ) || ''
101102 this . _related = this . getParent ( ) ?. getFirstValue ( ) || null
102103 this . _hideSubtaks = + this . vtodo . getFirstPropertyValue ( 'x-oc-hidesubtasks' ) || 0
103104 this . _hideCompletedSubtaks = + this . vtodo . getFirstPropertyValue ( 'x-oc-hidecompletedsubtasks' ) || 0
104105 this . _start = this . vtodo . getFirstPropertyValue ( 'dtstart' )
105- this . _startMoment = dayjs ( this . _start , 'YYYYMMDDTHHmmssZ' )
106+ this . _startMoment = moment ( this . _start , 'YYYYMMDDTHHmmssZ' )
106107 this . _due = this . vtodo . getFirstPropertyValue ( 'due' )
107- this . _dueMoment = dayjs ( this . _due , 'YYYYMMDDTHHmmssZ' )
108+ this . _dueMoment = moment ( this . _due , 'YYYYMMDDTHHmmssZ' )
108109 const start = this . vtodo . getFirstPropertyValue ( 'dtstart' )
109110 const due = this . vtodo . getFirstPropertyValue ( 'due' )
110111 const d = due || start
111112 this . _allDay = d !== null && d . isDate
112113 this . _loaded = false
113114 this . _tags = this . getTags ( )
114115 this . _modified = this . vtodo . getFirstPropertyValue ( 'last-modified' )
115- this . _modifiedMoment = dayjs ( this . _modified , 'YYYYMMDDTHHmmssZ' )
116+ this . _modifiedMoment = moment ( this . _modified , 'YYYYMMDDTHHmmssZ' )
116117 this . _created = this . vtodo . getFirstPropertyValue ( 'created' )
117- this . _createdMoment = dayjs ( this . _created , 'YYYYMMDDTHHmmssZ' )
118+ this . _createdMoment = moment ( this . _created , 'YYYYMMDDTHHmmssZ' )
118119 this . _class = this . vtodo . getFirstPropertyValue ( 'class' ) || 'PUBLIC'
119120 this . _pinned = this . vtodo . getFirstPropertyValue ( 'x-pinned' ) === 'true'
120121 this . _location = this . vtodo . getFirstPropertyValue ( 'location' ) || ''
@@ -315,11 +316,11 @@ export default class Task {
315316 }
316317 this . vtodo . updatePropertyWithValue ( 'completed' , completedDate )
317318 this . _completedDate = completedDate
318- this . _completedDateMoment = dayjs ( completedDate , 'YYYYMMDDTHHmmssZ' )
319+ this . _completedDateMoment = moment ( completedDate , 'YYYYMMDDTHHmmssZ' )
319320 } else {
320321 this . vtodo . removeProperty ( 'completed' )
321322 this . _completedDate = null
322- this . _completedDateMoment = dayjs ( null )
323+ this . _completedDateMoment = moment ( null )
323324 }
324325 this . _completed = completed
325326 this . updateLastModified ( )
@@ -503,7 +504,7 @@ export default class Task {
503504 this . vtodo . removeProperty ( 'dtstart' )
504505 }
505506 this . _start = start
506- this . _startMoment = dayjs ( start , 'YYYYMMDDTHHmmssZ' )
507+ this . _startMoment = moment ( start , 'YYYYMMDDTHHmmssZ' )
507508 this . updateLastModified ( )
508509 // Check all day setting
509510 const d = this . _due || this . _start
@@ -529,7 +530,7 @@ export default class Task {
529530 this . vtodo . removeProperty ( 'due' )
530531 }
531532 this . _due = due
532- this . _dueMoment = dayjs ( due , 'YYYYMMDDTHHmmssZ' )
533+ this . _dueMoment = moment ( due , 'YYYYMMDDTHHmmssZ' )
533534 this . updateLastModified ( )
534535 // Check all day setting
535536 const d = this . _due || this . _start
@@ -550,7 +551,7 @@ export default class Task {
550551 start . isDate = allDay
551552 if ( ! allDay ) {
552553 // If we converted to datetime, we set the hour to zero in the current timezone.
553- this . setStart ( ICAL . Time . fromJSDate ( dayjs ( start , 'YYYYMMDDTHHmmssZ' ) . toDate ( ) , true ) )
554+ this . setStart ( ICAL . Time . fromJSDate ( moment ( start , 'YYYYMMDDTHHmmssZ' ) . toDate ( ) , true ) )
554555 } else {
555556 this . setStart ( ICAL . Time . fromDateString ( this . _startMoment . format ( 'YYYY-MM-DD' ) ) )
556557 }
@@ -560,7 +561,7 @@ export default class Task {
560561 due . isDate = allDay
561562 if ( ! allDay ) {
562563 // If we converted to datetime, we set the hour to zero in the current timezone.
563- this . setDue ( ICAL . Time . fromJSDate ( dayjs ( due , 'YYYYMMDDTHHmmssZ' ) . toDate ( ) , true ) )
564+ this . setDue ( ICAL . Time . fromJSDate ( moment ( due , 'YYYYMMDDTHHmmssZ' ) . toDate ( ) , true ) )
564565 } else {
565566 this . setDue ( ICAL . Time . fromDateString ( this . _dueMoment . format ( 'YYYY-MM-DD' ) ) )
566567 }
@@ -708,7 +709,7 @@ export default class Task {
708709 this . vtodo . updatePropertyWithValue ( 'last-modified' , now )
709710 this . vtodo . updatePropertyWithValue ( 'dtstamp' , now )
710711 this . _modified = now
711- this . _modifiedMoment = dayjs ( now , 'YYYYMMDDTHHmmssZ' )
712+ this . _modifiedMoment = moment ( now , 'YYYYMMDDTHHmmssZ' )
712713 }
713714
714715 get modified ( ) {
@@ -730,7 +731,7 @@ export default class Task {
730731 set created ( createdDate ) {
731732 this . vtodo . updatePropertyWithValue ( 'created' , createdDate )
732733 this . _created = createdDate
733- this . _createdMoment = dayjs ( createdDate , 'YYYYMMDDTHHmmssZ' )
734+ this . _createdMoment = moment ( createdDate , 'YYYYMMDDTHHmmssZ' )
734735 // Update the sortorder if necessary
735736 if ( this . vtodo . getFirstPropertyValue ( 'x-apple-sort-order' ) === null ) {
736737 this . _sortOrder = this . getSortOrder ( )
0 commit comments