MDL-50364 forms: calendar header renderer uses translated months

This commit is contained in:
Jayce Birrell
2026-01-09 13:52:59 +10:30
parent 9699514341
commit a38ed9f2a3
5 changed files with 67 additions and 6 deletions
@@ -106,6 +106,25 @@ M.form.dateselector = {
showPrevMonth: true,
showNextMonth: true,
firstdayofweek: parseInt(config.firstdayofweek, 10),
headerRenderer: function(date) {
// We fetch the current language's preferred time format from the language pack.
var calendar = this;
require(['core/user_date', 'core/notification'], function(UserDate, Notification) {
UserDate.get([{
timestamp: Math.floor(date.getTime() / 1000),
format: config.strftimemonthyear,
}]).then(function(dateStrs) {
var headerNode = calendar.get('contentBox')
.one('#' + calendar._calendarId + '_header');
if (headerNode) {
headerNode.setContent(dateStrs[0]);
}
return dateStrs[0];
}).catch(Notification.exception);
});
return '';
},
WEEKDAYS_MEDIUM: [
config.sun,
config.mon,
@@ -113,7 +132,8 @@ M.form.dateselector = {
config.wed,
config.thu,
config.fri,
config.sat]
config.sat,
],
});
},
findZIndex: function(node) {
File diff suppressed because one or more lines are too long
@@ -106,6 +106,25 @@ M.form.dateselector = {
showPrevMonth: true,
showNextMonth: true,
firstdayofweek: parseInt(config.firstdayofweek, 10),
headerRenderer: function(date) {
// We fetch the current language's preferred time format from the language pack.
var calendar = this;
require(['core/user_date', 'core/notification'], function(UserDate, Notification) {
UserDate.get([{
timestamp: Math.floor(date.getTime() / 1000),
format: config.strftimemonthyear,
}]).then(function(dateStrs) {
var headerNode = calendar.get('contentBox')
.one('#' + calendar._calendarId + '_header');
if (headerNode) {
headerNode.setContent(dateStrs[0]);
}
return dateStrs[0];
}).catch(Notification.exception);
});
return '';
},
WEEKDAYS_MEDIUM: [
config.sun,
config.mon,
@@ -113,7 +132,8 @@ M.form.dateselector = {
config.wed,
config.thu,
config.fri,
config.sat]
config.sat,
],
});
},
findZIndex: function(node) {
+21 -1
View File
@@ -102,6 +102,25 @@ M.form.dateselector = {
showPrevMonth: true,
showNextMonth: true,
firstdayofweek: parseInt(config.firstdayofweek, 10),
headerRenderer: function(date) {
// We fetch the current language's preferred time format from the language pack.
var calendar = this;
require(['core/user_date', 'core/notification'], function(UserDate, Notification) {
UserDate.get([{
timestamp: Math.floor(date.getTime() / 1000),
format: config.strftimemonthyear,
}]).then(function(dateStrs) {
var headerNode = calendar.get('contentBox')
.one('#' + calendar._calendarId + '_header');
if (headerNode) {
headerNode.setContent(dateStrs[0]);
}
return dateStrs[0];
}).catch(Notification.exception);
});
return '';
},
WEEKDAYS_MEDIUM: [
config.sun,
config.mon,
@@ -109,7 +128,8 @@ M.form.dateselector = {
config.wed,
config.thu,
config.fri,
config.sat]
config.sat,
],
});
},
findZIndex: function(node) {
+2 -1
View File
@@ -107,7 +107,8 @@ function form_init_date_js() {
'september' => date_format_string(strtotime("September 1"), '%B', $defaulttimezone),
'october' => date_format_string(strtotime("October 1"), '%B', $defaulttimezone),
'november' => date_format_string(strtotime("November 1"), '%B', $defaulttimezone),
'december' => date_format_string(strtotime("December 1"), '%B', $defaulttimezone)
'december' => date_format_string(strtotime("December 1"), '%B', $defaulttimezone),
'strftimemonthyear' => get_string('strftimemonthyear', 'langconfig'),
));
$PAGE->requires->yui_module($module, $function, $config);
}