Skip to content

Commit 9d5e0a9

Browse files
committed
fix(ui): remove moment usage from due date badge
Signed-off-by: grnd-alt <git@belakkaf.net>
1 parent 3d2eb22 commit 9d5e0a9

1 file changed

Lines changed: 5 additions & 10 deletions

File tree

src/components/cards/badges/DueDate.vue

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818

1919
<script>
2020
import { mapState } from 'vuex'
21-
import moment from '@nextcloud/moment'
2221
import Clock from 'vue-material-design-icons/Clock.vue'
2322
import ClockOutline from 'vue-material-design-icons/ClockOutline.vue'
2423
import CheckCircle from 'vue-material-design-icons/CheckCircle.vue'
24+
import { useFormatTime, useFormatRelativeTime } from '@nextcloud/vue'
2525
2626
const DueState = {
2727
Done: 'Done',
@@ -51,7 +51,7 @@ export default {
5151
if (this.card.done) {
5252
return DueState.Done
5353
}
54-
const days = Math.floor(moment(this.card.duedate).diff(this.$root.time, 'seconds') / 60 / 60 / 24)
54+
const days = Math.floor((new Date(this.card.duedate).getTime() - new Date(this.$root.time).getTime()) / 60 / 60 / 24 / 1000)
5555
if (days < 0) {
5656
return DueState.Overdue
5757
}
@@ -68,16 +68,11 @@ export default {
6868
return this.dueState === DueState.Overdue
6969
},
7070
relativeDate() {
71-
const date = this.card.done ? this.card.done : this.card.duedate
72-
const diff = moment(this.$root.time).diff(date, 'seconds')
73-
if (diff >= 0 && diff < 45) {
74-
return t('core', 'seconds ago')
75-
}
76-
return moment(date).fromNow()
71+
return useFormatRelativeTime(this.card.done ? this.card.done : this.card.duedate).value
7772
},
7873
absoluteDate() {
79-
const date = this.card.done ? this.card.done : this.card.duedate
80-
return moment(date).format('LLLL')
74+
const date = new Date(this.card.done ? this.card.done : this.card.duedate)
75+
return useFormatTime(date, { format: { dateStyle: 'full', timeStyle: 'short' } }).value
8176
},
8277
},
8378
}

0 commit comments

Comments
 (0)