Skip to content

Commit

Permalink
fix: count month days for teams challenge days left
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Bedon committed May 15, 2024
1 parent d0a44cd commit f073f37
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/plugins/team-goal-mixin.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { intervalToDuration } from 'date-fns';
import { intervalToDuration, getDaysInMonth } from 'date-fns';

export default {
props: {
Expand Down Expand Up @@ -48,10 +48,17 @@ 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();
return intervalToDuration({
const interval = intervalToDuration({
start,
end,
}).days;
});

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

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

0 comments on commit f073f37

Please sign in to comment.