2323 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
2424 *
2525 */
26-
27- import moment from '@nextcloud/moment'
26+ import dayjs from 'dayjs'
2827
2928import ICAL from 'ical.js'
3029import { randomUUID } from '../utils/crypto.js'
@@ -95,27 +94,27 @@ export default class Task {
9594 this . _priority = this . vtodo . getFirstPropertyValue ( 'priority' ) || 0
9695 this . _complete = this . vtodo . getFirstPropertyValue ( 'percent-complete' ) || 0
9796 this . _completedDate = this . vtodo . getFirstPropertyValue ( 'completed' )
98- this . _completedDateMoment = moment ( this . _completedDate , 'YYYYMMDDTHHmmssZ' )
97+ this . _completedDateMoment = dayjs ( this . _completedDate , 'YYYYMMDDTHHmmssZ' )
9998 this . _completed = ! ! this . _completedDate
10099 this . _status = this . vtodo . getFirstPropertyValue ( 'status' )
101100 this . _note = this . vtodo . getFirstPropertyValue ( 'description' ) || ''
102101 this . _related = this . getParent ( ) ?. getFirstValue ( ) || null
103102 this . _hideSubtaks = + this . vtodo . getFirstPropertyValue ( 'x-oc-hidesubtasks' ) || 0
104103 this . _hideCompletedSubtaks = + this . vtodo . getFirstPropertyValue ( 'x-oc-hidecompletedsubtasks' ) || 0
105104 this . _start = this . vtodo . getFirstPropertyValue ( 'dtstart' )
106- this . _startMoment = moment ( this . _start , 'YYYYMMDDTHHmmssZ' )
105+ this . _startMoment = dayjs ( this . _start , 'YYYYMMDDTHHmmssZ' )
107106 this . _due = this . vtodo . getFirstPropertyValue ( 'due' )
108- this . _dueMoment = moment ( this . _due , 'YYYYMMDDTHHmmssZ' )
107+ this . _dueMoment = dayjs ( this . _due , 'YYYYMMDDTHHmmssZ' )
109108 const start = this . vtodo . getFirstPropertyValue ( 'dtstart' )
110109 const due = this . vtodo . getFirstPropertyValue ( 'due' )
111110 const d = due || start
112111 this . _allDay = d !== null && d . isDate
113112 this . _loaded = false
114113 this . _tags = this . getTags ( )
115114 this . _modified = this . vtodo . getFirstPropertyValue ( 'last-modified' )
116- this . _modifiedMoment = moment ( this . _modified , 'YYYYMMDDTHHmmssZ' )
115+ this . _modifiedMoment = dayjs ( this . _modified , 'YYYYMMDDTHHmmssZ' )
117116 this . _created = this . vtodo . getFirstPropertyValue ( 'created' )
118- this . _createdMoment = moment ( this . _created , 'YYYYMMDDTHHmmssZ' )
117+ this . _createdMoment = dayjs ( this . _created , 'YYYYMMDDTHHmmssZ' )
119118 this . _class = this . vtodo . getFirstPropertyValue ( 'class' ) || 'PUBLIC'
120119 this . _pinned = this . vtodo . getFirstPropertyValue ( 'x-pinned' ) === 'true'
121120 this . _location = this . vtodo . getFirstPropertyValue ( 'location' ) || ''
@@ -316,11 +315,11 @@ export default class Task {
316315 }
317316 this . vtodo . updatePropertyWithValue ( 'completed' , completedDate )
318317 this . _completedDate = completedDate
319- this . _completedDateMoment = moment ( completedDate , 'YYYYMMDDTHHmmssZ' )
318+ this . _completedDateMoment = dayjs ( completedDate , 'YYYYMMDDTHHmmssZ' )
320319 } else {
321320 this . vtodo . removeProperty ( 'completed' )
322321 this . _completedDate = null
323- this . _completedDateMoment = moment ( null )
322+ this . _completedDateMoment = dayjs ( null )
324323 }
325324 this . _completed = completed
326325 this . updateLastModified ( )
@@ -504,7 +503,7 @@ export default class Task {
504503 this . vtodo . removeProperty ( 'dtstart' )
505504 }
506505 this . _start = start
507- this . _startMoment = moment ( start , 'YYYYMMDDTHHmmssZ' )
506+ this . _startMoment = dayjs ( start , 'YYYYMMDDTHHmmssZ' )
508507 this . updateLastModified ( )
509508 // Check all day setting
510509 const d = this . _due || this . _start
@@ -530,7 +529,7 @@ export default class Task {
530529 this . vtodo . removeProperty ( 'due' )
531530 }
532531 this . _due = due
533- this . _dueMoment = moment ( due , 'YYYYMMDDTHHmmssZ' )
532+ this . _dueMoment = dayjs ( due , 'YYYYMMDDTHHmmssZ' )
534533 this . updateLastModified ( )
535534 // Check all day setting
536535 const d = this . _due || this . _start
@@ -551,7 +550,7 @@ export default class Task {
551550 start . isDate = allDay
552551 if ( ! allDay ) {
553552 // If we converted to datetime, we set the hour to zero in the current timezone.
554- this . setStart ( ICAL . Time . fromJSDate ( moment ( start , 'YYYYMMDDTHHmmssZ' ) . toDate ( ) , true ) )
553+ this . setStart ( ICAL . Time . fromJSDate ( dayjs ( start , 'YYYYMMDDTHHmmssZ' ) . toDate ( ) , true ) )
555554 } else {
556555 this . setStart ( ICAL . Time . fromDateString ( this . _startMoment . format ( 'YYYY-MM-DD' ) ) )
557556 }
@@ -561,7 +560,7 @@ export default class Task {
561560 due . isDate = allDay
562561 if ( ! allDay ) {
563562 // If we converted to datetime, we set the hour to zero in the current timezone.
564- this . setDue ( ICAL . Time . fromJSDate ( moment ( due , 'YYYYMMDDTHHmmssZ' ) . toDate ( ) , true ) )
563+ this . setDue ( ICAL . Time . fromJSDate ( dayjs ( due , 'YYYYMMDDTHHmmssZ' ) . toDate ( ) , true ) )
565564 } else {
566565 this . setDue ( ICAL . Time . fromDateString ( this . _dueMoment . format ( 'YYYY-MM-DD' ) ) )
567566 }
@@ -709,7 +708,7 @@ export default class Task {
709708 this . vtodo . updatePropertyWithValue ( 'last-modified' , now )
710709 this . vtodo . updatePropertyWithValue ( 'dtstamp' , now )
711710 this . _modified = now
712- this . _modifiedMoment = moment ( now , 'YYYYMMDDTHHmmssZ' )
711+ this . _modifiedMoment = dayjs ( now , 'YYYYMMDDTHHmmssZ' )
713712 }
714713
715714 get modified ( ) {
@@ -731,7 +730,7 @@ export default class Task {
731730 set created ( createdDate ) {
732731 this . vtodo . updatePropertyWithValue ( 'created' , createdDate )
733732 this . _created = createdDate
734- this . _createdMoment = moment ( createdDate , 'YYYYMMDDTHHmmssZ' )
733+ this . _createdMoment = dayjs ( createdDate , 'YYYYMMDDTHHmmssZ' )
735734 // Update the sortorder if necessary
736735 if ( this . vtodo . getFirstPropertyValue ( 'x-apple-sort-order' ) === null ) {
737736 this . _sortOrder = this . getSortOrder ( )
0 commit comments