Skip to content

Commit

Permalink
Merge pull request #282 from dmouriss/fix-build-from-date-id
Browse files Browse the repository at this point in the history
Fix build from date
  • Loading branch information
Yooooomi authored Oct 19, 2023
2 parents 9ef4235 + 9128bd5 commit 6a3235e
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions client/src/services/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@ export const fresh = (d: Date, eraseHour = false) => {
};

export const buildFromDateId = (dateId: DateId) => {
const date = fresh(new Date());
date.setFullYear(dateId.year);
date.setMonth((dateId.month ?? 1) - 1);
date.setDate(dateId.day ?? 1);
date.setHours(dateId.hour ?? 0);
const date = fresh(
new Date(
dateId.year,
(dateId.month ?? 1) - 1,
dateId.day ?? 1,
dateId.hour ?? 0,
),
);
return date;
};

Expand Down

0 comments on commit 6a3235e

Please sign in to comment.