Bug 1380751 - Use mozIntl in minimonth.xml. r=MakeMyDay
authorJorg K <jorgk@jorgk.com>
Wed, 19 Jul 2017 14:43:16 +0200
changeset 28459 c581127bdaff3f5f3cfbee6af84f5e7290a79773
parent 28458 36c79355c7779d7198aa242e94f58738b6e467ca
child 28460 7a2ed081a9cb7e8fbb653d8c051951a34afa2649
push id1986
push userclokep@gmail.com
push dateWed, 02 Aug 2017 14:43:31 +0000
treeherdercomm-beta@b51c9adf2c9e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMakeMyDay
bugs1380751
Bug 1380751 - Use mozIntl in minimonth.xml. r=MakeMyDay
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">