Zend Framework

Zend_Date DST fix adjusts by +23 hours instead of -1.

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Critical Critical
  • Resolution: Fixed
  • Affects Version/s: 1.7.4
  • Fix Version/s: 1.8.0
  • Component/s: Zend_Date
  • Labels:
    None

Description

Given the following code example to reproduce:

date_default_timezone_set('Europe/Berlin');

$dt = array(
            'year' => '2009',
            'month' => '01',
            'day' => '28',
            'hour' => '23',
            'minute' => '30',
            'second' => '00'
);	    
	    
$zd = new Zend_Date($dt);
	    
echo $zd->toString("Y M d H m s");

// Expected: 2009 1 28 23 30 00
// Result: 2009 1 29 23 30 00

Tracing trough Zend/Date.php @ 214

// DST fix
            if ((is_array($date) === true) and (isset($date['hour']) === true)) {
                $hour = $this->toString('H');
                $hour = $date['hour'] - $hour;
                if ($hour !== 0) {
                    $this->addTimestamp($hour * 3600);
                }
            }

In the above code block, the first assignment to $hour sets it to 0;
The second assignment sets it to 23.
The conditional statement then adds 23 hours to the date instance.
I'm not sure what was intended here, but any DST correction should never exceed 1 hour.

Activity

Hide
Georg-Hendrik Haan added a comment -

Saving incorrectly resolved Zend_Date output may lead to (subtle) data loss.

Show
Georg-Hendrik Haan added a comment - Saving incorrectly resolved Zend_Date output may lead to (subtle) data loss.
Hide
Thomas Weidner added a comment -

Unittest added with r14045

Show
Thomas Weidner added a comment - Unittest added with r14045

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: