["worked around"] Date above 5.x-2.5 breaks dst adjustments logic

burlap - December 9, 2009 - 18:48
Project:Date
Version:5.x-2.x-dev
Component:PHP4 Module
Category:support request
Priority:normal
Assigned:Unassigned
Status:active
Description

I know I should be using PHP 5.2, but tell that my CentOS-addicted admins. Anyway, after upgrading date module above 2.5, dates on the day when DST is introduced (last Sunday of March) are pulled back one day (to last Saturday of March).

The changelog for date 2.6 says "Date PHP4: fix inconsistency in offset computation for first two hours of the day dst changes." but only brining back the lines below made it work again.

<?php
// Check yesterday's and tomorrow's offset in case dst happens this day.
    
$today_offset = date_get_gmt_diff_ts($timestamp, $timezone);
    
$yesterday_offset = date_get_gmt_diff_ts($timestamp - 86400, $timezone);
    
$tomorrow_offset = date_get_gmt_diff_ts($timestamp + 86400, $timezone);
    
     if (
$yesterday_offset != $tomorrow_offset && $yesterday_offset < 0) {
      
$adj = $yesterday_offset;
     }
     elseif (
$yesterday_offset != $tomorrow_offset && $tomorrow_offset > 0) {
      
$adj = $tomorrow_offset;
     }
     else {
      
$adj = $today_offset;
     }
    
$timestamp $timestamp + $adj;
?>

This is how it looks in date >2.5

<?php
if ($timezone != 'UTC') {
    
$timestamp += date_get_gmt_diff_ts($timestamp, $timezone);
    }
?>

I don't know the logic of PHP4 modules well enough to find out why the old works and the new does not. (And my knowledge of PHP is rather basic too).

I know the developers mentioned it many times that squashing bugs in PHP4 modules is a waste of time and effort, so rather than asking to correct it, I'll just leave it as a support request tagged with "worked around" instead of "solved". Perhaps it helps someone with similar issues and as stubborn server admins...

 
 

Drupal is a registered trademark of Dries Buytaert.