Bug 1262373 - Today pane: DST causes missing dates for events in the "Upcoming" section. r=merike
authorDecathlon <bv1578@gmail.com>
Thu, 21 Apr 2016 13:48:28 +0200
changeset 24835 1bb6fd6acf8487d0bb99458069ce46fc4b491e1f
parent 24834 57f4a5bbbb88de9cd7addd6cfbca67df916f8b2b
child 24836 aaf73ae87441d3361d7656c6bbec41f949b304f7
push id1657
push userclokep@gmail.com
push dateMon, 06 Jun 2016 19:50:21 +0000
treeherdercomm-beta@9fac989284b5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmerike
bugs1262373
Bug 1262373 - Today pane: DST causes missing dates for events in the "Upcoming" section. r=merike
calendar/base/content/agenda-listbox.js
calendar/base/content/agenda-listbox.xml
--- a/calendar/base/content/agenda-listbox.js
+++ b/calendar/base/content/agenda-listbox.js
@@ -1,19 +1,20 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 Components.utils.import("resource://gre/modules/Services.jsm");
 Components.utils.import("resource://gre/modules/Preferences.jsm");
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
 
-function Synthetic(aOpen, aDuration) {
+function Synthetic(aOpen, aDuration, aMultiday) {
     this.open = aOpen;
     this.duration = aDuration;
+    this.multiday = aMultiday;
 }
 
 var agendaListbox = {
     agendaListboxControl: null,
     mPendingRefreshJobs: null,
     kDefaultTimezone: null,
     showsToday: false,
     soonDays: 5
@@ -24,21 +25,21 @@ var agendaListbox = {
  */
 agendaListbox.init =
 function initAgendaListbox() {
     this.agendaListboxControl = document.getElementById("agenda-listbox");
     this.agendaListboxControl.removeAttribute("suppressonselect");
     var showTodayHeader = (document.getElementById("today-header-hidden").getAttribute("checked") == "true");
     var showTomorrowHeader = (document.getElementById("tomorrow-header-hidden").getAttribute("checked") == "true");
     var showSoonHeader = (document.getElementById("nextweek-header-hidden").getAttribute("checked") == "true");
-    this.today = new Synthetic(showTodayHeader, 1);
+    this.today = new Synthetic(showTodayHeader, 1, false);
     this.addPeriodListItem(this.today, "today-header");
-    this.tomorrow = new Synthetic(showTomorrowHeader, 1);
+    this.tomorrow = new Synthetic(showTomorrowHeader, 1, false);
     this.soonDays = getSoondaysPreference();
-    this.soon = new Synthetic(showSoonHeader, this.soonDays);
+    this.soon = new Synthetic(showSoonHeader, this.soonDays, true);
     this.periods = [this.today, this.tomorrow, this.soon];
     this.mPendingRefreshJobs = new Map();
 
     var prefObserver = {
         observe: function aL_observe(aSubject, aTopic, aPrefName) {
             switch (aPrefName) {
                 case "calendar.agendaListbox.soondays":
                     agendaListbox.soonDays = getSoondaysPreference();
--- a/calendar/base/content/agenda-listbox.xml
+++ b/calendar/base/content/agenda-listbox.xml
@@ -122,24 +122,24 @@
             periodStartDate.isDate = true;
             let periodEndDate = aPeriod.end;
             let startDate = this.mOccurrence[calGetStartDateProp(this.mOccurrence)]
                                 .getInTimezone(calendarDefaultTimezone());
             let endDate = this.mOccurrence[calGetEndDateProp(this.mOccurrence)]
                               .getInTimezone(calendarDefaultTimezone());
             let endPreviousDay = endDate.clone();
             endPreviousDay.day--;
-            let now = cal.now();
-            now.isDate = true;
-            let longPeriod = periodStartDate.subtractDate(now).days > 1;
+            // Show items's date for long periods but also for "Upcoming"
+            // period with one day duration.
+            let showDate = aPeriod.multiday || aPeriod.duration > 1;
 
             let date = "";
             let iconType = "";
             let allDayDateLabel = document.getAnonymousElementByAttribute(this, "anonid", "agenda-allDayEvent-date");
-            setBooleanAttribute(allDayDateLabel, "hidden", !longPeriod);
+            setBooleanAttribute(allDayDateLabel, "hidden", !showDate);
             if (startDate.compare(endPreviousDay) != 0) {
                 // All day event spanning multiple days.
                 if (startDate.compare(periodStartDate) >= 0 &&
                      startDate.compare(periodEndDate) <= 0) {
                     iconType = "start";
                     date = dateFormatter.formatDate(startDate);
                 } else if (endDate.compare(periodStartDate) >= 0 &&
                            endDate.compare(periodEndDate) <= 0) {
@@ -214,19 +214,19 @@
             let startDate = start.clone();
             startDate.isDate = true;
             let endDate = end.clone();
             endDate.isDate = true;
             let endAtMidnight = (end.hour == 0 && end.minute == 0);
             if (endAtMidnight) {
                 endDate.day--;
             }
-            let now = cal.now();
-            now.isDate = true;
-            let longFormat = periodStartDate.subtractDate(now).days > 1;
+            // Show items's date for long periods but also for "Upcoming"
+            // period with one day duration.
+            let longFormat = aPeriod.multiday || aPeriod.duration > 1;
 
             let duration = "";
             let iconType = "";
             if (startDate.compare(endDate) == 0) {
                 // event that starts and ends in the same day, midnight included
                 duration = longFormat ? dateFormatter.formatDateTime(start) :
                                         dateFormatter.formatTime(start);
             } else {