Skip to content
Snippets Groups Projects
Unverified Commit 13d0584f authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3016427 by sysosmaster, nod_, kkalashnikov, Neslee Canil Pinto,...

Issue #3016427 by sysosmaster, nod_, kkalashnikov, Neslee Canil Pinto, alexpott, quicksketch: Default timezone selection incorrect
parent 79835b02
No related branches found
No related tags found
8 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!1012Issue #3226887: Hreflang on non-canonical content pages,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10,!596Issue #3046532: deleting an entity reference field, used in a contextual view, makes the whole site unrecoverable,!496Issue #2463967: Use .user.ini file for PHP settings,!144Issue #2666286: Clean up menu_ui to conform to Drupal coding standards,!16Draft: Resolve #2081585 "History storage",!13Resolve #2903456
......@@ -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,
......
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment