1
0
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:
Marc Alexander
2024-10-06 17:41:17 +02:00
parent ae8a5e791e
commit 36de1a49b1
4 changed files with 24 additions and 1 deletions

View File

@@ -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