mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-05 00:07:44 +02:00
[ticket/14404] Set board & admin timezone based on browser timezone
PHPBB-14404
This commit is contained in:
@@ -605,6 +605,8 @@
|
||||
function interceptFormSubmit($form) {
|
||||
if (!$form.length) {
|
||||
return;
|
||||
} else if ($form.find('input[name="admin_name"]').length > 0) {
|
||||
setAdminTimezone($form);
|
||||
}
|
||||
|
||||
$form.find(':submit').bind('click', function (event) {
|
||||
@@ -612,4 +614,20 @@
|
||||
submitForm($form, $(this));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Set admin timezone in form
|
||||
*
|
||||
* @param $form
|
||||
*/
|
||||
function setAdminTimezone($form) {
|
||||
// Set admin timezone if it does not exist yet
|
||||
if ($form.find('input[name="admin_timezone"]').length === 0) {
|
||||
const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
||||
|
||||
// Add timezone as form entry
|
||||
const timezoneEntry = $('<input type="hidden" name="admin_timezone" value="' + timeZone + '">');
|
||||
$form.append(timezoneEntry);
|
||||
}
|
||||
}
|
||||
})(jQuery); // Avoid conflicts with other libraries
|
||||
|
Reference in New Issue
Block a user