Fix bug 403241 - automated test fails when iCal string does not contain a start date. r=ctalbert
authorAndy Lawrence <andy.lawrence@gmail.com>
Sat, 05 Mar 2011 16:27:36 +0100
changeset 7258 bcb38f072c3ee03e71b3ea68b26ffa8176f131e1
parent 7257 8b87f8b2ef0b2ecb5310438c5831385bdd9e7f61
child 7259 7c2bd99a597d43ba61690c8a0822323b72d79e97
push idunknown
push userunknown
push dateunknown
reviewersctalbert
bugs403241
Fix bug 403241 - automated test fails when iCal string does not contain a start date. r=ctalbert
calendar/base/src/calEvent.js
--- a/calendar/base/src/calEvent.js
+++ b/calendar/base/src/calEvent.js
@@ -106,17 +106,22 @@ calEvent.prototype = {
         return m;
     },
 
     makeImmutable: function () {
         this.makeItemBaseImmutable();
     },
 
     get duration() {
-        return this.endDate.subtractDate(this.startDate);
+        if (this.endDate && this.startDate) {
+            return this.endDate.subtractDate(this.startDate);
+        } else {
+            // Return a null-duration if we don't have an end date
+            return cal.createDuration();
+        }
     },
 
     get recurrenceStartDate() {
         return this.startDate;
     },
 
     icsEventPropMap: [
     { cal: "DTSTART", ics: "startTime" },
@@ -209,17 +214,17 @@ calEvent.prototype = {
         return this.getProperty("DTSTART");
     },
 
     mEndDate: undefined,
     get endDate() {
         var endDate = this.mEndDate;
         if (endDate === undefined) {
             endDate = this.getProperty("DTEND");
-            if (!endDate) {
+            if (!endDate && this.startDate) {
                 endDate = this.startDate.clone();
                 var dur = this.getProperty("DURATION");
                 if (dur) {
                     // If there is a duration set on the event, calculate the right end time.
                     endDate.addDuration(cal.createDuration(dur));
                 } else {
                     // If the start time is a date-time the event ends on the same calendar
                     // date and time of day. If the start time is a date the events