ZF-5735: Zend_Date DST fix adjusts by +23 hours instead of -1.
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.
Comments
Posted by Georg-Hendrik Haan (haan) on 2009-02-10T15:33:17.000+0000
Saving incorrectly resolved Zend_Date output may lead to (subtle) data loss.
Posted by Thomas Weidner (thomas) on 2009-02-10T23:27:36.000+0000
Unittest added with r14045