Issue #3016427 by sysosmaster, nod_, kkalashnikov, Neslee Canil Pinto, alexpott, quicksketch: Default timezone selection incorrect

merge-requests/2419/head
Alex Pott 2020-06-08 16:33:42 +01:00
parent 79835b0256
commit 13d0584f61
No known key found for this signature in database
GPG Key ID: 31905460D4A69276
2 changed files with 15 additions and 0 deletions

View File

@ -15,6 +15,14 @@
.find('.timezone-detect')
.once('timezone');
if ($timezone.length) {
const tz = new Intl.DateTimeFormat().resolvedOptions().timeZone;
// Ensure that the timezone value returned by the browser is supported
// by the server.
if (tz && $timezone.find(`option[value="${tz}"]`).length) {
$timezone.val(tz);
return;
}
const dateString = Date();
// In some client environments, date strings include a time zone
// abbreviation, between 3 and 5 letters enclosed in parentheses,

View File

@ -11,6 +11,13 @@
var $timezone = $(context).find('.timezone-detect').once('timezone');
if ($timezone.length) {
var tz = new Intl.DateTimeFormat().resolvedOptions().timeZone;
if (tz && $timezone.find("option[value=\"".concat(tz, "\"]")).length) {
$timezone.val(tz);
return;
}
var dateString = Date();
var matches = dateString.match(/\(([A-Z]{3,5})\)/);
var abbreviation = matches ? matches[1] : 0;