Bug 1272980 - Email convert to calendar event sometimes sets event start time later than end time disabling save. r=philipp
authorMerike Sell <merike.sell@eesti.ee>
Tue, 07 Jun 2016 13:38:00 +0200
changeset 25274 209456d7f0f099985a19208fe39055fb8a1abed2
parent 25273 516a17742688a2ae370ea6931c5fef4217892d99
child 25275 3706aefd2bdc7748a40822de36fff19d82cfb4cb
push id1725
push userclokep@gmail.com
push dateMon, 19 Sep 2016 17:35:08 +0000
treeherdercomm-beta@6ead1abf3817 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersphilipp
bugs1272980
Bug 1272980 - Email convert to calendar event sometimes sets event start time later than end time disabling save. r=philipp
calendar/base/modules/calExtract.jsm
--- a/calendar/base/modules/calExtract.jsm
+++ b/calendar/base/modules/calExtract.jsm
@@ -954,20 +954,22 @@ Extractor.prototype = {
                     guess.day = endTime.getDate();
                     if (!(endTime.getHours() == 0 && endTime.getMinutes() == 0)) {
                         guess.hour = endTime.getHours()
                         guess.minute = endTime.getMinutes();
                     }
                 }
             }
 
-            // no zero length events/tasks
-            if (guess.year == start.year && guess.month == start.month &&
-                guess.day == start.day && guess.hour == start.hour &&
-                guess.minute == start.minute) {
+            // no zero or negative length events/tasks
+            let startTime = new Date(start.year || 0, start.month - 1 || 0, start.day || 0,
+                                     start.hour || 0, start.minute || 0).getTime();
+            let guessTime = new Date(guess.year || 0, guess.month - 1 || 0, guess.day || 0,
+                                     guess.hour || 0, guess.minute || 0).getTime();
+            if (guessTime <= startTime) {
                 guess.year = null;
                 guess.month = null;
                 guess.day = null;
                 guess.hour = null;
                 guess.minute = null;
             }
 
             if (guess.year != null && guess.minute == null && isTask) {