X-Git-Url: https://yaffs.net/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmisc%2Ftimezone.js;h=62ea880e23fcf8c149d6c24bd1b1a43abe549458;hb=4e1bfbf98b844da83b18aca92ef00f11a4735806;hp=3c88d463dd805ae5a3f83bac4a62c778baf14712;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/web/core/misc/timezone.js b/web/core/misc/timezone.js index 3c88d463d..62ea880e2 100644 --- a/web/core/misc/timezone.js +++ b/web/core/misc/timezone.js @@ -1,69 +1,45 @@ /** - * @file - * Timezone detection. - */ +* DO NOT EDIT THIS FILE. +* See the following change record for more information, +* https://www.drupal.org/node/2815083 +* @preserve +**/ (function ($, Drupal) { - - 'use strict'; - - /** - * Set the client's system time zone as default values of form fields. - * - * @type {Drupal~behavior} - */ Drupal.behaviors.setTimezone = { - attach: function (context, settings) { + attach: function attach(context, settings) { var $timezone = $(context).find('.timezone-detect').once('timezone'); if ($timezone.length) { var dateString = Date(); - // In some client environments, date strings include a time zone - // abbreviation, between 3 and 5 letters enclosed in parentheses, - // which can be interpreted by PHP. + var matches = dateString.match(/\(([A-Z]{3,5})\)/); var abbreviation = matches ? matches[1] : 0; - // For all other client environments, the abbreviation is set to "0" - // and the current offset from UTC and daylight saving time status are - // used to guess the time zone. var dateNow = new Date(); var offsetNow = dateNow.getTimezoneOffset() * -60; - // Use January 1 and July 1 as test dates for determining daylight - // saving time status by comparing their offsets. var dateJan = new Date(dateNow.getFullYear(), 0, 1, 12, 0, 0, 0); var dateJul = new Date(dateNow.getFullYear(), 6, 1, 12, 0, 0, 0); var offsetJan = dateJan.getTimezoneOffset() * -60; var offsetJul = dateJul.getTimezoneOffset() * -60; - var isDaylightSavingTime; - // If the offset from UTC is identical on January 1 and July 1, - // assume daylight saving time is not used in this time zone. + var isDaylightSavingTime = void 0; + if (offsetJan === offsetJul) { isDaylightSavingTime = ''; - } - // If the maximum annual offset is equivalent to the current offset, - // assume daylight saving time is in effect. - else if (Math.max(offsetJan, offsetJul) === offsetNow) { - isDaylightSavingTime = 1; - } - // Otherwise, assume daylight saving time is not in effect. - else { - isDaylightSavingTime = 0; - } + } else if (Math.max(offsetJan, offsetJul) === offsetNow) { + isDaylightSavingTime = 1; + } else { + isDaylightSavingTime = 0; + } - // Submit request to the system/timezone callback and set the form - // field to the response time zone. The client date is passed to the - // callback for debugging purposes. Submit a synchronous request to - // avoid database errors associated with concurrent requests - // during install. var path = 'system/timezone/' + abbreviation + '/' + offsetNow + '/' + isDaylightSavingTime; $.ajax({ async: false, url: Drupal.url(path), - data: {date: dateString}, + data: { date: dateString }, dataType: 'json', - success: function (data) { + success: function success(data) { if (data) { $timezone.val(data); } @@ -72,5 +48,4 @@ } } }; - -})(jQuery, Drupal); +})(jQuery, Drupal); \ No newline at end of file