Bug 956544 - The Edit Event dialog shows wrong date-times with timezones enabled after closing and reopening. r=mmecca, a=philipp
authorDecathlon <bv1578@gmail.com>
Wed, 22 Jan 2014 22:26:23 +0100
changeset 16999 c30f5de3a316d6b52365081d6c4e822d5209ecfe
parent 16998 f451248a298e160b80f7bc38fda9b6c4974acc83
child 17000 3963845c0351371119a97dfd62610de60c14426f
push id1074
push userbugzilla@standard8.plus.com
push dateMon, 03 Feb 2014 22:47:23 +0000
treeherdercomm-beta@6b791b5369ed [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmmecca, philipp
bugs956544
Bug 956544 - The Edit Event dialog shows wrong date-times with timezones enabled after closing and reopening. r=mmecca, a=philipp
calendar/base/content/dialogs/calendar-event-dialog.js
--- a/calendar/base/content/dialogs/calendar-event-dialog.js
+++ b/calendar/base/content/dialogs/calendar-event-dialog.js
@@ -618,18 +618,18 @@ function dateTimeControls2State(aStartDa
         startWidgetId = "todo-entrydate";
         endWidgetId = "todo-duedate";
     }
 
     var saveStartTime = gStartTime;
     var saveEndTime = gEndTime;
     var kDefaultTimezone = calendarDefaultTimezone();
 
-    let timezonesEnabled = document.getElementById('options-timezones-menuitem')
-                           .getAttribute('checked') == 'true';
+    let timezonesEnabled = document.getElementById('cmd_timezone')
+                                   .getAttribute('checked') == 'true';
     if (gStartTime) {
         // jsDate is always in OS timezone, thus we create a calIDateTime
         // object from the jsDate representation then we convert the timezone
         // in order to keep gStartTime in default timezone.
         gStartTime = cal.jsDateToDateTime(getElementValue(startWidgetId),
                                           (timezonesEnabled || allDay) ? gStartTimezone : kDefaultTimezone);
         if (timezonesEnabled || allDay) {
             gStartTime = gStartTime.getInTimezone(kDefaultTimezone);
@@ -1158,18 +1158,19 @@ function updateAccept() {
     } else {
         startDate = getElementValue("todo-has-entrydate", "checked") ?
             cal.jsDateToDateTime(getElementValue("todo-entrydate")) : null;
         endDate = getElementValue("todo-has-duedate", "checked") ?
             cal.jsDateToDateTime(getElementValue("todo-duedate")) : null;
     }
 
     if (startDate && endDate) {
-        var menuItem = document.getElementById('options-timezones-menuitem');
-        if (menuItem.getAttribute('checked') == 'true') {
+        let timezonesEnabled = document.getElementById('cmd_timezone')
+                                       .getAttribute('checked') == 'true';
+        if (timezonesEnabled) {
             var startTimezone = gStartTimezone;
             var endTimezone = gEndTimezone;
             if (endTimezone.isUTC) {
                 if (!compareObjects(gStartTimezone, gEndTimezone)) {
                     endTimezone = gStartTimezone;
                 }
             }
 
@@ -1430,18 +1431,18 @@ function editAttendees() {
         startTime.isDate = true;
         endTime.isDate = true;
         endTime.day += 1;
     } else {
         startTime.isDate = false;
         endTime.isDate = false;
     }
 
-    var menuItem = document.getElementById('options-timezones-menuitem');
-    var displayTimezone = menuItem.getAttribute('checked') == 'true';
+    let displayTimezone = document.getElementById('cmd_timezone')
+                                  .getAttribute('checked') == 'true';
 
     var args = new Object();
     args.startTime = startTime;
     args.endTime = endTime;
     args.displayTimezone = displayTimezone;
     args.attendees = window.attendees;
     args.organizer = window.organizer && window.organizer.clone();
     args.calendar = calendar;
@@ -3085,32 +3086,33 @@ function editTimezone(aElementId,aDateTi
  * - 'event-endtime'
  * - 'event-all-day'
  * - 'todo-has-entrydate'
  * - 'todo-entrydate'
  * - 'todo-has-duedate'
  * - 'todo-duedate'
  * The date/time-objects are either displayed in their respective
  * timezone or in the default timezone. This decision is based
- * on whether or not 'options-timezones-menuitem' is checked.
+ * on whether or not 'cmd_timezone' is checked.
  * the necessary information is taken from the following variables:
  * - 'gStartTime'
  * - 'gEndTime'
  * - 'window.calendarItem' (used to decide about event/task)
  */
 function updateDateTime() {
     gIgnoreUpdate = true;
 
-    var item = window.calendarItem;
-    var menuItem = document.getElementById('options-timezones-menuitem');
+    let item = window.calendarItem;
+    let timezonesEnabled = document.getElementById('cmd_timezone')
+                                   .getAttribute('checked') == 'true';
 
     // Convert to default timezone if the timezone option
     // is *not* checked, otherwise keep the specific timezone
     // and display the labels in order to modify the timezone.
-    if (menuItem.getAttribute('checked') == 'true') {
+    if (timezonesEnabled) {
         if (isEvent(item)) {
           var startTime = gStartTime.getInTimezone(gStartTimezone);
           var endTime = gEndTime.getInTimezone(gEndTimezone);
 
           setElementValue("event-all-day", startTime.isDate, "checked");
 
           // In the case where the timezones are different but
           // the timezone of the endtime is "UTC", we convert
@@ -3234,26 +3236,26 @@ function updateDateTime() {
     gIgnoreUpdate = false;
 }
 
 /**
  * This function initializes the following controls:
  * - 'timezone-starttime'
  * - 'timezone-endtime'
  * the timezone-links show the corrosponding names of the
- * start/end times. if 'options-timezones-menuitem' is not checked
+ * start/end times. If 'cmd_timezone' is not checked
  * the links will be collapsed.
  */
 function updateTimezone() {
-    let timezoneCommand = document.getElementById('cmd_timezone');
-
+    let timezonesEnabled = document.getElementById('cmd_timezone')
+                                   .getAttribute('checked') == 'true';
     // convert to default timezone if the timezone option
     // is *not* checked, otherwise keep the specific timezone
     // and display the labels in order to modify the timezone.
-    if (timezoneCommand.getAttribute('checked') == 'true') {
+    if (timezonesEnabled) {
         let startTimezone = gStartTimezone;
         let endTimezone = gEndTimezone;
 
         function updateTimezoneElement(aTimezone, aId, aDateTime) {
             let element = document.getElementById(aId);
             if (!element) {
                 return;
             }