mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 06:37:23 +01:00
Modify relative dueIn time on tasks to be in days (#9251)
* Modify relative dueIn time on tasks to be in days - Normalizes the current time and task due time to the ends of their respective days. - Returns 'today' if the dates are the same day else uses moment's humanize function to allow for weeks, months, years and so on. * Modify task due date to appear grey when due the next day
This commit is contained in:
committed by
Matteo Pagliazzi
parent
52064f6b2a
commit
46a8ee52d4
@@ -595,13 +595,22 @@ export default {
|
||||
if (this.task.type === 'habit' && (this.task.up || this.task.down)) return true;
|
||||
return false;
|
||||
},
|
||||
timeTillDue () {
|
||||
// this.task && is necessary to make sure the computed property updates correctly
|
||||
const endOfToday = moment().endOf('day');
|
||||
const endOfDueDate = moment(this.task && this.task.date).endOf('day');
|
||||
|
||||
return moment.duration(endOfDueDate.diff(endOfToday));
|
||||
},
|
||||
isDueOverdue () {
|
||||
return moment().diff(this.task.date, 'days') >= 0;
|
||||
return this.timeTillDue.asDays() <= 0;
|
||||
},
|
||||
dueIn () {
|
||||
// this.task && is necessary to make sure the computed property updates correctly
|
||||
const dueIn = moment().to(this.task && this.task.date);
|
||||
return this.$t('dueIn', {dueIn});
|
||||
const dueIn = this.timeTillDue.asDays() === 0 ?
|
||||
this.$t('today') :
|
||||
this.timeTillDue.humanize(true);
|
||||
|
||||
return this.$t('dueIn', { dueIn });
|
||||
},
|
||||
hasTags () {
|
||||
return this.task.tags && this.task.tags.length > 0;
|
||||
|
||||
Reference in New Issue
Block a user