Skip to content

Commit

Permalink
refactor: using difference in days
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Bedon committed May 15, 2024
1 parent f073f37 commit f398fd0
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions src/plugins/team-goal-mixin.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { intervalToDuration, getDaysInMonth } from 'date-fns';
import { differenceInDays } from 'date-fns';

export default {
props: {
Expand Down Expand Up @@ -48,17 +48,10 @@ export default {
daysLeft() {
const start = this.goal?.startDate ? new Date(this.goal?.startDate) : new Date();
const end = this.goal?.endDate ? new Date(this.goal?.endDate) : new Date();
const interval = intervalToDuration({
start,
return differenceInDays(
end,
});

if (interval?.months) {
const daysInMonth = getDaysInMonth(start);
return interval.days + (interval.months * daysInMonth);
}

return interval?.days ?? 0;
start,
);
},
challengeDescription() {
return this.goal?.description ?? '';
Expand Down

0 comments on commit f398fd0

Please sign in to comment.