--- includes/common.inc.old 2006-10-05 09:31:03.000000000 +0200 +++ includes/common.inc 2006-10-05 08:43:10.000000000 +0200 @@ -894,6 +894,9 @@ } else { $timezone = variable_get('date_default_timezone', 0); + if (variable_get('daylight_saving_time', 0) && drupal_is_dst($timestamp)) { + $timestamp += 3600; + } } } @@ -1422,3 +1425,56 @@ } } } + + +/** + * Check if time is in Daylight Savings Time + * + * @param + * $timestamp a timestamp + * @return + * 0 or 1 + */ +function drupal_is_dst($timestamp) { + $year = date('Y'); + $timezone = variable_get('date_default_timezone', 0); + + // Information on Daylight Saving time was obtained from http://webexhibits.org/daylightsaving/g.html + switch (variable_get('daylight_saving_time', 0)) { + case 0: + return 0; + case 1: // EU and other European countries + // start of DST (last Sunday in March 1 am GMT) + $dststart = strtotime("-1 week sunday GMT", strtotime("1 april $year GMT")) + 3600; + // end of DST in Europe (last Sunday in October 1 am GMT) + $dstend = strtotime("-1 week sunday GMT", strtotime("1 november $year GMT")) + 3600; + break; + case 2: // Russian Federation + // start of DST (last Sunday in March 2 am local time) + $dststart = strtotime("-1 week sunday GMT", strtotime("1 april $year GMT")) + 7200 + $timezone; + // end of DST (last Sunday in October 2 am local time) + $dstend = strtotime("-1 week sunday GMT", strtotime("1 november $year GMT")) + 7200 + $timezone; + break; + case 3: // Northern America (where applicable) + // start of DST (where applicable) (first Sunday in April 2 am local time) + $dststart = strtotime("1 week sunday GMT", strtotime("1 april $year GMT")) + 7200 + $timezone; + // end of DST (where applicable) (last Sunday in October 2 am local time) + $dstend = strtotime("-1 week sunday GMT", strtotime("1 november $year GMT")) + 7200 + $timezone; + break; + case 4: // Australia + // start of DST (last Sunday in October) + $dststart = strtotime("-1 week sunday GMT", strtotime("1 november $year GMT")) + $timezone; + // end of DST (last Sunday in March) + $dstend = strtotime("-1 week sunday GMT", strtotime("1 april $year GMT")) + $timezone; + break; + case 5: // New Zealand + // start of DST (last Sunday in October) + $dststart = strtotime("-1 week sunday GMT", strtotime("1 november $year GMT")) + $timezone; + // end of DST (third Sunday in March) + $dstend = strtotime("3 week sunday GMT", strtotime("1 march $year GMT")) + $timezone; + break; + } + + return ($dststart <= $timestamp && $timestamp <= $dstend); +} + --- modules/node.module.old 2006-10-05 09:33:05.000000000 +0200 +++ modules/node.module 2006-10-05 08:45:10.000000000 +0200 @@ -1571,6 +1571,15 @@ if (!isset($node->date)) { $node->date = format_date($node->created, 'custom', 'Y-m-d H:i:s O'); + if (!variable_get('configurable_timezones', 1)) { + $node->date = format_date($node->created, 'custom', 'Y-m-d H:i'); + if (drupal_is_dst($node->date)) { + $node->date -= 3600; + } + } + else { + $node->date = format_date($node->created, 'custom', 'Y-m-d H:i O'); + } } } node_invoke($node, 'prepare'); --- modules/system.module.old 2006-10-05 09:33:13.000000000 +0200 +++ modules/system.module 2006-10-05 09:11:36.000000000 +0200 @@ -398,6 +398,15 @@ // Date settings: $zones = _system_zonelist(); + // Daylight saving time settings + $dst = array(t('None'), + t('EU and other European countries'), + t('Russian Federation'), + t('Northern America (where applicable)'), + t('Australia (where applicable)'), + t('New Zealand') + ); + // Date settings: possible date formats $dateshort = array('Y-m-d H:i','m/d/Y - H:i', 'd/m/Y - H:i', 'Y/m/d - H:i', 'd.m.Y - H:i', 'm/d/Y - g:ia', 'd/m/Y - g:ia', 'Y/m/d - g:ia', @@ -427,6 +436,11 @@ '#options' => $zones, '#description' => t('Select the default site time zone.') ); + $form['dates']['daylight_saving_time'] = array( + '#type' => 'radios', '#title' => t('Daylight saving time '), '#default_value' => variable_get('daylight_saving_time', 0), '#options' => $dst, + '#description' => t('Select the Daylight saving time setting (DST) appropriate for your site. Takes only effect if configurable time zones are disabled. If chosing a setting here, make sure you set your default time zone to standard time.') + ); + $form['dates']['configurable_timezones'] = array( '#type' => 'radios', '#title' => t('Configurable time zones'), '#default_value' => variable_get('configurable_timezones', 1), '#options' => array(t('Disabled'), t('Enabled')), '#description' => t('Enable or disable user-configurable time zones. When enabled, users can set their own time zone and dates will be updated accordingly.')