Merge pull request #2684 from michael-genson/fix/mealplan-date-off-by-one

fix: Mealplanner Date Off By One (Daylight Savings)
This commit is contained in:
boc-the-git 2023-10-27 12:09:09 +11:00 committed by GitHub
commit 4ec7bd4352
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -79,7 +79,6 @@ export default defineComponent({
});
if (sorted.length === 2) {
console.log(parseYYYYMMDD(sorted[0]));
return {
start: parseYYYYMMDD(sorted[0]),
end: parseYYYYMMDD(sorted[1]),
@ -105,11 +104,15 @@ export default defineComponent({
const numDays =
Math.floor((weekRange.value.end.getTime() - weekRange.value.start.getTime()) / (1000 * 60 * 60 * 24)) + 1;
// Calculate aboslute value
// Calculate absolute value
if (numDays < 0) return [];
return Array.from(Array(numDays).keys()).map(
(i) => new Date(weekRange.value.start.getTime() + i * 24 * 60 * 60 * 1000)
(i) => {
const date = new Date(weekRange.value.start.getTime());
date.setDate(date.getDate() + i);
return date;
}
);
});