Fix get_beginning_of_week#380
Conversation
fix get_beginning_of_week returning wrong results when given $date is not a start of the week fix get_beginning_of_week returning wrong results on DST switching
|
Concerning the DST problem, I replaced the calculation of the week offset, which was done by adding a fixed amount of seconds, with the use of strtotime like this: I'm not all too familiar with PHP but I hope this will be fine. At least this seems to respect DST changes. |
|
I added another commit, also fixing the same error in the corresponding method get_ending_of_week. In this case the error resulted in the database query selecting a too short week range for weeks after the DST change whereby all sundays after the change appeared empty in the calendar. |
Crazy find! Given how gnarly this method is (and how critical it is to making sure the calendar renders correctly) can you add a test-edit-flow-calendar.php file with a few tests that make sure it executes correctly in normal situations as well as funky ones (i.e., DST change in between start and end of week). Also, would hopefully test a few international date situations as well (if you know of any interesting one's to test for)! Will review after that test is in and then work on merging. Thanks! |
|
This looks good to me, however, I'm hesitant to include it in 0.8.3 without tests. I'm tentatively marking this for 0.8.3. @sboisvert care you chime in? @FewKinG will you be open to adding tests? I realize that it's been way too long since the PR, and priorities most likely have shifted for you :) |

The method get_beginning_of_week has some flaws which I addressed in this commit.