2323 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
2424 *
2525 */
26+ import dayjs from 'dayjs'
2627
2728import ICAL from 'ical.js'
2829import { randomUUID } from '../utils/crypto.js'
@@ -93,27 +94,27 @@ export default class Task {
9394 this . _priority = this . vtodo . getFirstPropertyValue ( 'priority' ) || 0
9495 this . _complete = this . vtodo . getFirstPropertyValue ( 'percent-complete' ) || 0
9596 this . _completedDate = this . vtodo . getFirstPropertyValue ( 'completed' )
96- this . _completedDateMoment = moment ( this . _completedDate , 'YYYYMMDDTHHmmssZ' )
97+ this . _completedDateMoment = dayjs ( this . _completedDate , 'YYYYMMDDTHHmmssZ' )
9798 this . _completed = ! ! this . _completedDate
9899 this . _status = this . vtodo . getFirstPropertyValue ( 'status' )
99100 this . _note = this . vtodo . getFirstPropertyValue ( 'description' ) || ''
100101 this . _related = this . getParent ( ) ?. getFirstValue ( ) || null
101102 this . _hideSubtaks = + this . vtodo . getFirstPropertyValue ( 'x-oc-hidesubtasks' ) || 0
102103 this . _hideCompletedSubtaks = + this . vtodo . getFirstPropertyValue ( 'x-oc-hidecompletedsubtasks' ) || 0
103104 this . _start = this . vtodo . getFirstPropertyValue ( 'dtstart' )
104- this . _startMoment = moment ( this . _start , 'YYYYMMDDTHHmmssZ' )
105+ this . _startMoment = dayjs ( this . _start , 'YYYYMMDDTHHmmssZ' )
105106 this . _due = this . vtodo . getFirstPropertyValue ( 'due' )
106- this . _dueMoment = moment ( this . _due , 'YYYYMMDDTHHmmssZ' )
107+ this . _dueMoment = dayjs ( this . _due , 'YYYYMMDDTHHmmssZ' )
107108 const start = this . vtodo . getFirstPropertyValue ( 'dtstart' )
108109 const due = this . vtodo . getFirstPropertyValue ( 'due' )
109110 const d = due || start
110111 this . _allDay = d !== null && d . isDate
111112 this . _loaded = false
112113 this . _tags = this . getTags ( )
113114 this . _modified = this . vtodo . getFirstPropertyValue ( 'last-modified' )
114- this . _modifiedMoment = moment ( this . _modified , 'YYYYMMDDTHHmmssZ' )
115+ this . _modifiedMoment = dayjs ( this . _modified , 'YYYYMMDDTHHmmssZ' )
115116 this . _created = this . vtodo . getFirstPropertyValue ( 'created' )
116- this . _createdMoment = moment ( this . _created , 'YYYYMMDDTHHmmssZ' )
117+ this . _createdMoment = dayjs ( this . _created , 'YYYYMMDDTHHmmssZ' )
117118 this . _class = this . vtodo . getFirstPropertyValue ( 'class' ) || 'PUBLIC'
118119 this . _pinned = this . vtodo . getFirstPropertyValue ( 'x-pinned' ) === 'true'
119120 this . _location = this . vtodo . getFirstPropertyValue ( 'location' ) || ''
@@ -314,11 +315,11 @@ export default class Task {
314315 }
315316 this . vtodo . updatePropertyWithValue ( 'completed' , completedDate )
316317 this . _completedDate = completedDate
317- this . _completedDateMoment = moment ( completedDate , 'YYYYMMDDTHHmmssZ' )
318+ this . _completedDateMoment = dayjs ( completedDate , 'YYYYMMDDTHHmmssZ' )
318319 } else {
319320 this . vtodo . removeProperty ( 'completed' )
320321 this . _completedDate = null
321- this . _completedDateMoment = moment ( null )
322+ this . _completedDateMoment = dayjs ( null )
322323 }
323324 this . _completed = completed
324325 this . updateLastModified ( )
@@ -502,7 +503,7 @@ export default class Task {
502503 this . vtodo . removeProperty ( 'dtstart' )
503504 }
504505 this . _start = start
505- this . _startMoment = moment ( start , 'YYYYMMDDTHHmmssZ' )
506+ this . _startMoment = dayjs ( start , 'YYYYMMDDTHHmmssZ' )
506507 this . updateLastModified ( )
507508 // Check all day setting
508509 const d = this . _due || this . _start
@@ -528,7 +529,7 @@ export default class Task {
528529 this . vtodo . removeProperty ( 'due' )
529530 }
530531 this . _due = due
531- this . _dueMoment = moment ( due , 'YYYYMMDDTHHmmssZ' )
532+ this . _dueMoment = dayjs ( due , 'YYYYMMDDTHHmmssZ' )
532533 this . updateLastModified ( )
533534 // Check all day setting
534535 const d = this . _due || this . _start
@@ -549,7 +550,7 @@ export default class Task {
549550 start . isDate = allDay
550551 if ( ! allDay ) {
551552 // If we converted to datetime, we set the hour to zero in the current timezone.
552- this . setStart ( ICAL . Time . fromJSDate ( moment ( start , 'YYYYMMDDTHHmmssZ' ) . toDate ( ) , true ) )
553+ this . setStart ( ICAL . Time . fromJSDate ( dayjs ( start , 'YYYYMMDDTHHmmssZ' ) . toDate ( ) , true ) )
553554 } else {
554555 this . setStart ( ICAL . Time . fromDateString ( this . _startMoment . format ( 'YYYY-MM-DD' ) ) )
555556 }
@@ -559,7 +560,7 @@ export default class Task {
559560 due . isDate = allDay
560561 if ( ! allDay ) {
561562 // If we converted to datetime, we set the hour to zero in the current timezone.
562- this . setDue ( ICAL . Time . fromJSDate ( moment ( due , 'YYYYMMDDTHHmmssZ' ) . toDate ( ) , true ) )
563+ this . setDue ( ICAL . Time . fromJSDate ( dayjs ( due , 'YYYYMMDDTHHmmssZ' ) . toDate ( ) , true ) )
563564 } else {
564565 this . setDue ( ICAL . Time . fromDateString ( this . _dueMoment . format ( 'YYYY-MM-DD' ) ) )
565566 }
@@ -707,7 +708,7 @@ export default class Task {
707708 this . vtodo . updatePropertyWithValue ( 'last-modified' , now )
708709 this . vtodo . updatePropertyWithValue ( 'dtstamp' , now )
709710 this . _modified = now
710- this . _modifiedMoment = moment ( now , 'YYYYMMDDTHHmmssZ' )
711+ this . _modifiedMoment = dayjs ( now , 'YYYYMMDDTHHmmssZ' )
711712 }
712713
713714 get modified ( ) {
@@ -729,7 +730,7 @@ export default class Task {
729730 set created ( createdDate ) {
730731 this . vtodo . updatePropertyWithValue ( 'created' , createdDate )
731732 this . _created = createdDate
732- this . _createdMoment = moment ( createdDate , 'YYYYMMDDTHHmmssZ' )
733+ this . _createdMoment = dayjs ( createdDate , 'YYYYMMDDTHHmmssZ' )
733734 // Update the sortorder if necessary
734735 if ( this . vtodo . getFirstPropertyValue ( 'x-apple-sort-order' ) === null ) {
735736 this . _sortOrder = this . getSortOrder ( )
0 commit comments