# HG changeset patch # User Geoff Lankow # Date 1534928321 -43200 # Node ID b94f1e4b62e6effb2d18941caf6787394ca29cba # Parent 3275d30455dd4558839617fa0fe1f226645f3bdf Bug 1008735 - When changing timezones, wait until timezone service is ready before updating views. r=philipp diff --git a/calendar/base/content/calendar-base-view.xml b/calendar/base/content/calendar-base-view.xml --- a/calendar/base/content/calendar-base-view.xml +++ b/calendar/base/content/calendar-base-view.xml @@ -247,16 +247,17 @@ alarmService.addObserver(this.mObserver); this.setAttribute("type", this.type); this.mResizeHandler = () => { this.onResize(this); }; this.viewBroadcaster.addEventListener(this.getAttribute("type") + "viewresized", this.mResizeHandler, true); // add a preference observer to monitor changes Services.prefs.addObserver("calendar.", this.mPrefObserver); + Services.obs.addObserver(this.mTimezoneObserver, "defaultTimezoneChanged"); this.weekStartOffset = Preferences.get("calendar.week.start", 0); this.updateDaysOffPrefs(); this.mPendingRefreshJobs = new Map(); this.mLog = Log4Moz.getConfiguredLogger("calBaseView"); this.mFlashingEvents = {}; ]]> @@ -627,20 +629,16 @@ case "calendar.week.d1mondaysoff": case "calendar.week.d2tuesdaysoff": case "calendar.week.d3wednesdaysoff": case "calendar.week.d4thursdaysoff": case "calendar.week.d5fridaysoff": case "calendar.week.d6saturdaysoff": this.updateDaysOffPrefs(); break; - case "calendar.timezone.local": - this.timezone = cal.dtz.defaultTimezone; - this.refreshView(); - break; case "calendar.alarms.indicator.show": // Break here to ensure the view is refreshed break; case "calendar.week.start": this.weekStartOffset = aSubject.getIntPref(aPreference); break; case "calendar.date.format": case "calendar.view.showLocation": diff --git a/calendar/base/content/calendar-month-view.xml b/calendar/base/content/calendar-month-view.xml --- a/calendar/base/content/calendar-month-view.xml +++ b/calendar/base/content/calendar-month-view.xml @@ -82,23 +82,25 @@ this.mOccurrence = val; if (cal.item.isEvent(val)) { if (!val.startDate.isDate) { let label = document.getAnonymousElementByAttribute(this, "anonid", "item-label"); let formatter = Components.classes["@mozilla.org/calendar/datetime-formatter;1"] .getService(Components.interfaces.calIDateTimeFormatter); let timezone = this.calendarView ? this.calendarView.mTimezone : cal.dtz.defaultTimezone; - let parentDate = cal.dtz.ensureDateTime(this.parentBox.date); + let parentDate = this.parentBox.date; + let parentTime = cal.createDateTime(); + parentTime.resetTo(parentDate.year, parentDate.month, parentDate.day, 0, 0, 0, timezone); let startTime = val.startDate.getInTimezone(timezone); let endTime = val.endDate.getInTimezone(timezone); - let nextDay = parentDate.clone(); + let nextDay = parentTime.clone(); nextDay.day++; let comp = endTime.compare(nextDay); - if (startTime.compare(parentDate) == -1) { + if (startTime.compare(parentTime) == -1) { if (comp == 1) { label.value = "↔"; } else if (comp == 0) { label.value = "↤"; } else { label.value = "⇥ " + formatter.formatTime(endTime); } } else if (comp == 1) { @@ -441,16 +443,25 @@ null true true true null + { + this.timezone = cal.dtz.defaultTimezone; + this.refreshView(); + } + }) + ]]> + 0 0 9 * 60 null 15 null 0 + { + this.timezone = cal.dtz.defaultTimezone; + this.refreshView(); + this.updateTimeIndicatorPosition(true); + } + }) + ]]> + { + Services.obs.removeObserver(timezoneObserver, "defaultTimezoneChanged"); +}); diff --git a/calendar/base/content/today-pane.js b/calendar/base/content/today-pane.js --- a/calendar/base/content/today-pane.js +++ b/calendar/base/content/today-pane.js @@ -37,24 +37,34 @@ var TodayPane = { document.getElementById("modeBroadcaster").addEventListener("DOMAttrModified", TodayPane.onModeModified); TodayPane.setTodayHeader(); document.getElementById("today-splitter").addEventListener("command", onCalendarViewResize); TodayPane.updateSplitterState(); TodayPane.previousMode = document.getElementById("modeBroadcaster").getAttribute("mode"); TodayPane.showTodayPaneStatusLabel(); + + Services.obs.addObserver(TodayPane, "defaultTimezoneChanged"); }, /** * Unload handler, cleans up the today pane on window unload. */ onUnload: function() { document.getElementById("modeBroadcaster").removeEventListener("DOMAttrModified", TodayPane.onModeModified); document.getElementById("today-splitter").removeEventListener("command", onCalendarViewResize); + Services.obs.removeObserver(TodayPane, "defaultTimezoneChanged"); + }, + + /** + * React if the default timezone changes. + */ + observe: function() { + this.setDay(cal.dtz.now()); }, /** * Sets up the label for the switcher that allows switching between today pane * views. (event+task, task only, event only) */ setTodayHeader: function() { let currentMode = document.getElementById("modeBroadcaster").getAttribute("mode"); diff --git a/calendar/base/content/widgets/minimonth.xml b/calendar/base/content/widgets/minimonth.xml --- a/calendar/base/content/widgets/minimonth.xml +++ b/calendar/base/content/widgets/minimonth.xml @@ -932,16 +932,18 @@ if (aDate.getMonth() == date.getMonth() && aDate.getFullYear() == date.getFullYear()) { day.setAttribute("aria-label", date.toLocaleDateString(undefined, { day: "numeric" })); } else { day.setAttribute("aria-label", dateFormatter.format(date)); } + day.removeAttribute("busy"); + day.date = new Date(date); day.textContent = date.getDate(); date.setDate(date.getDate() + 1); if (monthChanged) { this.resetAttributesForDate(day.date); } } diff --git a/calendar/base/src/calTimezoneService.js b/calendar/base/src/calTimezoneService.js --- a/calendar/base/src/calTimezoneService.js +++ b/calendar/base/src/calTimezoneService.js @@ -275,16 +275,17 @@ calTimezoneService.prototype = { } }, observe: function(aSubject, aTopic, aData) { if (aTopic == "nsPref:changed" && aData == "calendar.timezone.local") { // Unsetting the default timezone will make the next call to the // default timezone getter set up the correct timezone again. this.mDefaultTimezone = null; + Services.obs.notifyObservers(null, "defaultTimezoneChanged"); } } }; /** * We're going to do everything in our power, short of rumaging through the * user's actual file-system, to figure out the time-zone they're in. The * deciding factors are the offsets given by (northern-hemisphere) summer and