Bug 1331608 - show every month exactly once in monthpicker. r?mconley
MozReview-Commit-ID: CNyo3d7PN8c
--- a/toolkit/content/widgets/datepicker.js
+++ b/toolkit/content/widgets/datepicker.js
@@ -280,30 +280,30 @@ function DatePicker(context) {
* {String} locale
* {Function} setYear
* {Function} setMonth
* }
* @param {DOMElement} context
*/
function MonthYear(options, context) {
const spinnerSize = 5;
- const monthFormat = new Intl.DateTimeFormat(options.locale, { month: "short" }).format;
+ const monthFormat = new Intl.DateTimeFormat(options.locale, { month: "short", timeZone: "UTC" }).format;
const yearFormat = new Intl.DateTimeFormat(options.locale, { year: "numeric" }).format;
const dateFormat = new Intl.DateTimeFormat(options.locale, { year: "numeric", month: "long" }).format;
this.context = context;
this.state = { dateFormat };
this.props = {};
this.components = {
month: new Spinner({
setValue: month => {
this.state.isMonthSet = true;
options.setMonth(month);
},
- getDisplayString: month => monthFormat(new Date(0, month)),
+ getDisplayString: month => monthFormat(new Date(Date.UTC(0, month))),
viewportSize: spinnerSize
}, context.monthYearView),
year: new Spinner({
setValue: year => {
this.state.isYearSet = true;
options.setYear(year);
},
getDisplayString: year => yearFormat(new Date(new Date(0).setFullYear(year))),
--- a/toolkit/content/widgets/datetimepicker.xml
+++ b/toolkit/content/widgets/datetimepicker.xml
@@ -982,23 +982,23 @@
return val;
</setter>
</property>
<method name="_init">
<body>
<![CDATA[
var locale = Intl.DateTimeFormat().resolvedOptions().locale + "-u-ca-gregory";
- var dtfMonth = Intl.DateTimeFormat(locale, {month: "long"});
+ var dtfMonth = Intl.DateTimeFormat(locale, {month: "long", timeZone: "UTC"});
var dtfWeekday = Intl.DateTimeFormat(locale, {weekday: "narrow"});
var monthLabel = this.monthField.firstChild;
- var tempDate = new Date(2005, 0, 1);
+ var tempDate = new Date(Date.UTC(2005, 0, 1));
for (var month = 0; month < 12; month++) {
- tempDate.setMonth(month);
+ tempDate.setUTCMonth(month);
monthLabel.setAttribute("value", dtfMonth.format(tempDate));
monthLabel = monthLabel.nextSibling;
}
var fdow = Number(this.getAttribute("firstdayofweek"));
if (!isNaN(fdow) && fdow >= 0 && fdow <= 6)
this._weekStart = fdow;