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

fix: Mealplanner Date Off By One (Daylight Savings) #2684

Conversation

michael-genson
Copy link
Collaborator

@michael-genson michael-genson commented Oct 25, 2023

What type of PR is this?

(REQUIRED)

  • bug

What this PR does / why we need it:

(REQUIRED)

As mentioned in Discord, the mealplanner has two November 5ths (easily reproducible on any instance):
image

I realized that November 5th is when daylight savings time ends, every developer's favorite time of year. Peeking at the code, I noticed there were two entries for November 5th: one at 0:00, and one at 23:00.

This fix tweaks the date calculation to increment by a day (using JS magic), rather than 24 * 60 * 60 * 1000 ms:

return Array.from(Array(numDays).keys()).map(
  (i) => {
    const date = new Date(weekRange.value.start.getTime());
    date.setDate(date.getDate() + i);
    return date;
  }
);

image

Which issue(s) this PR fixes:

(REQUIRED)

N/A, Discord

Testing

(fill-in or delete this section)

Locally. I checked some other red flag dates too just to make sure (e.g. next year's daylight savings).

Copy link
Collaborator

@boc-the-git boc-the-git left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@boc-the-git boc-the-git enabled auto-merge October 27, 2023 01:03
@boc-the-git boc-the-git merged commit 4ec7bd4 into mealie-recipes:mealie-next Oct 27, 2023
5 checks passed
@michael-genson michael-genson deleted the fix/mealplan-date-off-by-one branch October 27, 2023 03:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants