Issues

ZF-5277: fix_dst doesn`t work correctly

Description

In the following example, the fix_dst option doesn`t work correctly.


ini_set('date.timezone', 'UTC');

Zend_Date::setOptions(array('fix_dst' => true));

$date = new Zend_Date(mktime(22, 0, 0, 10, 25, 2008));
$date->setTimezone('Europe/Berlin');
$date->add(1, Zend_Date::DAY);
$date->sub(1, Zend_Date::SECOND);
echo $date->get(Zend_Date::DATE_SHORT) . ' ' . $date->get(Zend_Date::TIME_MEDIUM);

Current result: 26.10.08 22:59:59

Expected result: 26.10.08 23:59:59

This bugreport relates to a post in the german ZF-Forum. http://www.zfforum.de/showthread.php?t=2853

When I set the default timezone to Europe\Berlin and not to UTC it works, but this is not the required approach.

Comments

Debugging your example I get:


$date = new Zend_Date(mktime(22, 0, 0, 10, 25, 2008));

The date object contains


2008-10-25T22:00:00+00:00

which is correct... now you set the timezone


$date->setTimezone('Europe/Berlin');

and the object changes to


2008-10-26T00:00:00+02:00

which is correct because we are in summertime on this date so GMT+2 Now you add one day


$date->add(1, Zend_Date::DAY);

but there is a change from summer to wintertime... so the object changes to


2008-10-26T23:00:00+01:00

because this day has only 23 hours, but also the zone changes to GMT+1 Substracting one second makes no difference


$date->sub(1, Zend_Date::SECOND);

as the zone does not change on 22-23h.


2008-10-26T22:59:59+01:00

I see no problem at all.