Bug 1732753 follow-up - Fix events shown on the last day of a printed month. r=mkmelin
authorGeoff Lankow <geoff@darktrojan.net>
Wed, 29 Sep 2021 12:31:18 +0300
changeset 33892 18283be347b77bc25bbe67d5df8c25539e2efbcd
parent 33891 d9c0fd234078510cfb28b7de5ee1e9036253e0c9
child 33893 afe29de0d18877bcf706e6fe65af52879690c3f5
push id19210
push usermkmelin@iki.fi
push dateWed, 29 Sep 2021 09:52:30 +0000
treeherdercomm-central@d83e30472c11 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkmelin
bugs1732753
Bug 1732753 follow-up - Fix events shown on the last day of a printed month. r=mkmelin The calculated last day was wrong in two ways: * It was based on the first day after the month to be printed, so the value could be a week later than needed. This wouldn't be a problem, except that it covered up the other problem. * I didn't add a day, so events on the last day weren't displayed. (Because the end-of-week value was 00:00 of the last day, getItems didn't return items ON the last day.) Differential Revision: https://phabricator.services.mozilla.com/D126859
calendar/base/modules/utils/calPrintUtils.jsm
--- a/calendar/base/modules/utils/calPrintUtils.jsm
+++ b/calendar/base/modules/utils/calPrintUtils.jsm
@@ -351,17 +351,21 @@ let monthGridView = {
     let current = startDate.clone();
     do {
       container.appendChild(this.drawMonth(document, current));
       current.month += 1;
     } while (current.compare(endDate) < 0);
 
     // Extend the date range to include adjacent days that will be printed.
     startDate = weekInfoService.getStartOfWeek(startDate);
+    // Get the end of the week containing the last day of the month, not the
+    // week containing the first day of the next month.
+    endDate.day--;
     endDate = weekInfoService.getEndOfWeek(endDate);
+    endDate.day++; // Add a day to include items from the last day.
 
     // Get and display the items.
     let items = await getItems(startDate, endDate, filter, notDueTasks);
     let defaultTimezone = cal.dtz.defaultTimezone;
     for (let item of items) {
       let itemStartDate = item[cal.dtz.startDateProp(item)] || item[cal.dtz.endDateProp(item)];
       let itemEndDate = item[cal.dtz.endDateProp(item)] || item[cal.dtz.startDateProp(item)];