Index: misc/timezone.js =================================================================== RCS file: /cvs/drupal/drupal/misc/timezone.js,v retrieving revision 1.7 diff -u -9 -p -r1.7 timezone.js --- misc/timezone.js 31 Aug 2009 05:51:08 -0000 1.7 +++ misc/timezone.js 13 Apr 2010 18:36:36 -0000 @@ -5,19 +5,20 @@ * Set the client's system time zone as default values of form fields. */ Drupal.behaviors.setTimezone = { attach: function (context, settings) { $('select.timezone-detect', context).once('timezone', function () { 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 abbreviationPattern = /\(([A-Z]{3,5})\)/; + var matches = dateString.match(abbreviationPattern); 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 @@ -31,18 +32,30 @@ Drupal.behaviors.setTimezone = { // If the offset from UTC is identical on January 1 and July 1, // assume daylight saving time is not used in this time zone. 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; + + // On some client systems, the same time zone abbreviation is used for + // both offsets, e.g. 'CET' (Central European Time) is used both in + // January and July, even though the official abbreviation during + // daylight saving time is CEST (Central European Summer Time). This + // confuses PHP's timezone_name_from_abbr(), so omit the abbreviation + // during daylight saving time. + var matchesJan = dateJan.toString().match(abbreviationPattern); + var matchesJul = dateJul.toString().match(abbreviationPattern); + if (matchesJan && matchesJul && matchesJan[1] == matchesJul[1]) { + abbreviation = ''; + } } // Otherwise, assume daylight saving time is not in effect. 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