Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vinvoor: fix #114 timezone offset #119

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading