-
Notifications
You must be signed in to change notification settings - Fork 27
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 New Year Errors #8288
Fix New Year Errors #8288
Conversation
At the start and end of the year we need to pay special attention to the week, otherwise we get bad results.
Tests every single day around the year change against the reality we expect.
If we pass invalid data to this component such as a week that cannot exist in a year we should die much less horribly than we do right now. Kick out an error, and then don't display a title.
This test doesn't cover this issue.
Doing this by modifying the current year didn't work. I'm not 100% sure why, but the right way to run a single value into a Luxon DateTime is with fromObject so I switched to this. This prevents us from passing a bad combination of weeks in a year and the year and blowing up the page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code reviewed and click tested. LGTM.
// In this component the week always starts on Sunday, but luxon's starts on Monday | ||
// If today is sunday, we need to add a week to get the correct Thursday | ||
if (DateTime.now().weekday === 7) { | ||
return thursday.plus({ weeks: 1 }); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will need revisiting. Spanish and French locales have a start of the week on Monday, not Sunday.
Luxon provides a locale-aware function for getting the day-number of the start of the week. https://moment.github.io/luxon/api-docs/index.html#infogetstartofweek
Discovered several interconnected issues around the end of 2024 and the start of 2025. The most serious of these was that opening week at a glance all weeks for 2025 blew up as we were asking for 53 weeks in a 52 week year. This fixes ilios/ilios#5908.
I also discovered that the wrong title was appearing at the top of the dashboard week view during this time period as well.