Skip to content

Commit

Permalink
vinvoor: fix #114 timezone offset
Browse files Browse the repository at this point in the history
  • Loading branch information
redfast00 authored and Topvennie committed Dec 10, 2024
1 parent 79feb78 commit fc268cd
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions vinvoor/src/overview/heatmap/Day.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,11 @@ export const Day: FC<DayProps> = ({
<g key={idx}>
{isDayVariant(variant)
? Array.from({ length: DAYS_IN_WEEK }, (_, cidx) => {
const currentDate = new Date(
data.start.getTime()
+ MILLISECONDS_IN_DAY * (idx * DAYS_IN_WEEK + cidx),
);
const currentDate = new Date(data.start);
// This is a timezone safe way to add 1 day (see https://stackoverflow.com/questions/563406/how-to-add-days-to-date)
// The new date is guaranteed to have the same hour and minute value
// (in our case, already normalized to 0)
currentDate.setDate(currentDate.getDate() + (idx * DAYS_IN_WEEK + cidx));

if (currentDate.getTime() < startDate.getTime())
return null;
Expand Down

0 comments on commit fc268cd

Please sign in to comment.