Bug 1201838 - Printing tasks is broken [Error: TypeError: aItem[cal.calGetStartDateProp(...)] is null]. r=Fallen a=aleth
authorStefan Sitter <ssitter@gmail.com>
Fri, 04 Sep 2015 13:28:53 +0200
changeset 23098 c5e0f88e8a9f9034b15311f56434eee5ab90db4b
parent 23097 e70fab631b9f2b5eeacfef2ee88632fb5abb1499
child 23099 4b4e76877e1f53c0dd42197280f6f6033b5015c0
push id1474
push usermbanner@mozilla.com
push dateMon, 21 Sep 2015 17:20:48 +0000
treeherdercomm-beta@3094bab4c31f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersFallen, aleth
bugs1201838
Bug 1201838 - Printing tasks is broken [Error: TypeError: aItem[cal.calGetStartDateProp(...)] is null]. r=Fallen a=aleth
calendar/base/modules/calPrintUtils.jsm
calendar/import-export/calMonthGridPrinter.js
calendar/import-export/calWeekPrinter.js
--- a/calendar/base/modules/calPrintUtils.jsm
+++ b/calendar/base/modules/calPrintUtils.jsm
@@ -155,26 +155,31 @@ cal.print = {
     /**
      * Get time interval string for the given item. Returns an empty string for all-day items.
      *
      * @param aItem     The item providing the interval
      * @return          The string describing the interval
      */
     getItemIntervalString: function getItemIntervalString(aItem, aBoxDate) {
         // omit time label for all-day items
-        let defaultTz = cal.calendarDefaultTimezone();
-        let startDate = aItem[cal.calGetStartDateProp(aItem)].getInTimezone(defaultTz);
-        let endDate = aItem[cal.calGetEndDateProp(aItem)].getInTimezone(defaultTz);
+        let startDate = aItem[cal.calGetStartDateProp(aItem)];
+        let endDate = aItem[cal.calGetEndDateProp(aItem)];
         if ((startDate && startDate.isDate) || (endDate && endDate.isDate)) {
             return "";
         }
 
+        // check for tasks without start and/or due date
+        if (!startDate || !endDate) {
+            return cal.getDateFormatter().formatItemTimeInterval(aItem);
+        }
+
         let dateFormatter = cal.getDateFormatter();
-        let start = startDate.clone();
-        let end = endDate.clone();
+        let defaultTimezone = cal.calendarDefaultTimezone();
+        let start = startDate.getInTimezone(defaultTimezone).clone();
+        let end = endDate.getInTimezone(defaultTimezone).clone();
         start.isDate = true;
         end.isDate = true;
         if (start.compare(end) == 0) {
             // Events that start and end in the same day.
             return dateFormatter.formatTimeInterval(startDate, endDate);
         } else {
             // Events that span two or more days.
             let compareStart = aBoxDate.compare(start);
--- a/calendar/import-export/calMonthGridPrinter.js
+++ b/calendar/import-export/calMonthGridPrinter.js
@@ -54,23 +54,23 @@ calMonthPrinter.prototype = {
             {
                 this.setupMonth(document, current, dayTable);
             }
         }
 
         for each (let item in aItems) {
             let itemStartDate = item[cal.calGetStartDateProp(item)] || item[cal.calGetEndDateProp(item)];
             let itemEndDate = item[cal.calGetEndDateProp(item)] || item[cal.calGetStartDateProp(item)];
-            itemStartDate = itemStartDate.getInTimezone(defaultTimezone);
-            itemEndDate = itemEndDate.getInTimezone(defaultTimezone);
 
             if (!itemStartDate && !itemEndDate) {
                 cal.print.addItemToDayboxNodate(document, item);
                 continue;
             }
+            itemStartDate = itemStartDate.getInTimezone(defaultTimezone);
+            itemEndDate = itemEndDate.getInTimezone(defaultTimezone);
 
             let boxDate = itemStartDate.clone();
             boxDate.isDate = true;
             for (boxDate; boxDate.compare(itemEndDate) < (itemEndDate.isDate ? 0 : 1); boxDate.day++) {
                 // Ignore items outside of the range, i.e tasks without start date
                 // where the end date is somewhere else.
                 if (aStart && aEnd && boxDate &&
                     (boxDate.compare(aStart) < 0 || boxDate.compare(aEnd) >= 0)) {
--- a/calendar/import-export/calWeekPrinter.js
+++ b/calendar/import-export/calWeekPrinter.js
@@ -47,23 +47,23 @@ calWeekPrinter.prototype = {
             for (let current = weekInfoService.getStartOfWeek(aStart); current.compare(aEnd) < 0; current.day += 7) {
                 this.setupWeek(document, current, dayTable);
             }
         }
 
         for each (let item in aItems) {
             let itemStartDate = item[cal.calGetStartDateProp(item)] || item[cal.calGetEndDateProp(item)];
             let itemEndDate = item[cal.calGetEndDateProp(item)] || item[cal.calGetStartDateProp(item)];
-            itemStartDate = itemStartDate.getInTimezone(defaultTimezone);
-            itemEndDate = itemEndDate.getInTimezone(defaultTimezone);
 
             if (!itemStartDate && !itemEndDate) {
                 cal.print.addItemToDayboxNodate(document, item);
                 continue;
             }
+            itemStartDate = itemStartDate.getInTimezone(defaultTimezone);
+            itemEndDate = itemEndDate.getInTimezone(defaultTimezone);
 
             let boxDate = itemStartDate.clone();
             boxDate.isDate = true;
             for (boxDate; boxDate.compare(itemEndDate) < (itemEndDate.isDate ? 0 : 1); boxDate.day++) {
 
                 // Ignore items outside of the range, i.e tasks without start date
                 // where the end date is somewhere else.
                 if (aStart && aEnd && boxDate &&