mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-05-25 23:25:51 +00: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:
parent
52064f6b2a
commit
46a8ee52d4
1 changed files with 13 additions and 4 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue