Issues

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

Issue Type: Bug Created: 2009-02-10T15:26:52.000+0000 Last Updated: 2009-02-10T23:27:43.000+0000 Status: Resolved Fix version(s): - 1.8.0 (30/Apr/09)

Reporter: Georg-Hendrik Haan (haan) Assignee: Thomas Weidner (thomas) Tags: - Zend_Date

Related issues: Attachments:

Description

Given the following code example to reproduce:

<pre class="highlight">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

<pre class="highlight">
            // 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

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts