diff --git a/website/client/src/components/tasks/task.vue b/website/client/src/components/tasks/task.vue index 094c4f752f..8e15d60f93 100644 --- a/website/client/src/components/tasks/task.vue +++ b/website/client/src/components/tasks/task.vue @@ -223,14 +223,14 @@
- {{ dueIn }} + {{ formatDueDate() }}
0; }, @@ -1001,6 +983,22 @@ export default { item.completed = !item.completed; // @TODO this should go into the action? this.scoreChecklistItem({ taskId: this.task._id, itemId: item.id }); }, + calculateTimeTillDue () { + const endOfToday = moment().endOf('day'); + const endOfDueDate = moment(this.task.date).endOf('day'); + + return moment.duration(endOfDueDate.diff(endOfToday)); + }, + checkIfOverdue () { + return this.calculateTimeTillDue().asDays() <= 0; + }, + formatDueDate () { + const dueIn = this.calculateTimeTillDue().asDays() === 0 + ? this.$t('today') + : this.calculateTimeTillDue().humanize(true); + + return this.task.date && this.$t('dueIn', { dueIn }); + }, edit (e, task) { if (this.isRunningYesterdailies || !this.showEdit) return;