Bug 1370671 - DateTimeFormat timeZone set to UTC to show correct year-month header for datepicker. r=mconley
authorScott Wu <scottcwwu@gmail.com>
Wed, 07 Jun 2017 20:04:44 -0700
changeset 411457 d843dbc23708d592850e0381b8b9a872bc91345d
parent 411456 25b6519f489d6c103f794efcbeb0a2266d987fbd
child 411458 650ad20e9fea9b94e64de273578eced87250deb7
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley
bugs1370671, 1331608
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1370671 - DateTimeFormat timeZone set to UTC to show correct year-month header for datepicker. r=mconley The datepicker is showing incorrect year-month header in some time zones, which is similar to Bug 1331608. It's now fixed by setting the DateTimeFormat timeZone to UTC. Also done the same thing to the year display for consistency. MozReview-Commit-ID: LGghmPfYQ5j
toolkit/content/widgets/datepicker.js
--- a/toolkit/content/widgets/datepicker.js
+++ b/toolkit/content/widgets/datepicker.js
@@ -280,18 +280,21 @@ function DatePicker(context) {
    *          {Function} setMonth
    *          {Function} getMonthString
    *          {Array<String>} datetimeOrders
    *        }
    * @param {DOMElement} context
    */
   function MonthYear(options, context) {
     const spinnerSize = 5;
-    const yearFormat = new Intl.DateTimeFormat(options.locale, { year: "numeric" }).format;
-    const dateFormat = new Intl.DateTimeFormat(options.locale, { year: "numeric", month: "long" }).format;
+    const yearFormat = new Intl.DateTimeFormat(options.locale, { year: "numeric",
+                                                                 timeZone: "UTC" }).format;
+    const dateFormat = new Intl.DateTimeFormat(options.locale, { year: "numeric",
+                                                                 month: "long",
+                                                                 timeZone: "UTC" }).format;
     const spinnerOrder =
       options.datetimeOrders.indexOf("month") < options.datetimeOrders.indexOf("year") ?
       "order-month-year" : "order-year-month";
 
     context.monthYearView.classList.add(spinnerOrder);
 
     this.context = context;
     this.state = { dateFormat };
@@ -307,17 +310,17 @@ function DatePicker(context) {
         viewportSize: spinnerSize
       }, context.monthYearView),
       year: new Spinner({
         id: "spinner-year",
         setValue: year => {
           this.state.isYearSet = true;
           options.setYear(year);
         },
-        getDisplayString: year => yearFormat(new Date(new Date(0).setFullYear(year))),
+        getDisplayString: year => yearFormat(new Date(new Date(0).setUTCFullYear(year))),
         viewportSize: spinnerSize
       }, context.monthYearView)
     };
 
     this._attachEventListeners();
   }
 
   MonthYear.prototype = {