Bug 1380751 - Use mozIntl in minimonth.xml. r=MakeMyDay a=philipp DONTBUILD RELEASE_BASE_20170802
authorJorg K <jorgk@jorgk.com>
Wed, 19 Jul 2017 14:43:16 +0200
changeset 28330 72d7059579e0275a3755fed8f85b1baeb671e1a0
parent 28329 13c8920ec9a856084e0a922aedf87698eb8472f6
child 28331 76da6aebab8807fdf5da2aa2757273a9cabf69a8
push id1984
push usermozilla@jorgk.com
push dateTue, 01 Aug 2017 10:24:03 +0000
treeherdercomm-beta@72d7059579e0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMakeMyDay, philipp
bugs1380751
Bug 1380751 - Use mozIntl in minimonth.xml. r=MakeMyDay a=philipp DONTBUILD
calendar/base/content/widgets/minimonth.xml
--- a/calendar/base/content/widgets/minimonth.xml
+++ b/calendar/base/content/widgets/minimonth.xml
@@ -875,16 +875,18 @@
               calbox.setAttribute("aria-label", label);
           } else {
               calbox.setAttribute("aria-label", cal.calGetString("dateFormat",
                                   "month." + (aDate.getMonth() + 1) + ".name"));
           }
 
           this.mDayMap = {};
           let defaultTz = cal.calendarDefaultTimezone();
+          let dateFormatter =
+              Services.intl.createDateTimeFormat(undefined, { dateStyle: "long" });
           for (let k = 1; k < 7; k++) {
               // Set the week number.
               let firstElement = this._getCalBoxNode(k, 0);
               setBooleanAttribute(firstElement, "hidden", !this.mShowWeekNumber);
               if (this.mShowWeekNumber) {
                   let weekNumber = cal.getWeekInfoService()
                                       .getWeekTitle(cal.jsDateToDateTime(date, defaultTz));
                   let weekTitle = cal.calGetString("calendar", "WeekTitle", [weekNumber]);
@@ -923,24 +925,22 @@
                   }
 
                   // highlight the extra date
                   if (this._sameDay(this.mExtraDate, date)) {
                       this.mExtra = day;
                       day.setAttribute("extra", "true");
                   }
 
-                  let labelDateOptions = { day: 'numeric' };
-                  if (aDate.getMonth() != date.getMonth()) {
-                      labelDateOptions.month = 'long';
+                  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));
                   }
-                  if (aDate.getFullYear() != date.getFullYear()) {
-                      labelDateOptions.year = 'numeric';
-                  }
-                  day.setAttribute("aria-label", date.toLocaleDateString(undefined, labelDateOptions));
 
                   day.date = new Date(date);
                   day.textContent = date.getDate();
                   date.setDate(date.getDate() + 1);
 
                   if (monthChanged) {
                       this.resetAttributesForDate(day.date);
                   }
@@ -1080,18 +1080,19 @@
                             this);
         ]]></body>
       </method>
 
       <method name="updateAccessibleLabel">
         <body><![CDATA[
           var label;
           if (this.mValue) {
-              let labelDateOptions = { day: 'numeric', month: 'long', year: 'numeric' };
-              label = this.mValue.toLocaleDateString(undefined, labelDateOptions);
+              let dateFormatter =
+                  Services.intl.createDateTimeFormat(undefined, { dateStyle: "long" });
+              label = dateFormatter.format(this.mValue);
           } else {
               label = cal.calGetString("calendar", "minimonthNoSelectedDate");
           }
           this.setAttribute("aria-label", label);
         ]]></body>
       </method>
 
       <method name="update">