Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.5.0a4

Bug #14852 DST in Time Zones for dates in past are inaccurate
Submitted: 2008-10-22 20:40 UTC
From: markeb Assigned:
Status: Open Package: Date (version 1.5.0a1)
PHP Version: 5.2.1 OS: Windows
Roadmaps: (Not assigned)    
Subscription  


 [2008-10-22 20:40 UTC] markeb (Mark Bembnowski)
Description: ------------ The Daylight Saving Time adjustment of dates in the past is incorrect, whereas PHP's built-in DateTime class handles DST for dates in the past correctly. It is reasonable to suggest that the PEAR Date_TimeZone class should be able to be modified to include the same Time Zone data as the core PHP v5.1+ DateTimeZone class (I assume this is publicly available via the core PHP source code). ALSO, it is highly recommended that this be made a part of the PEAR Date_TimeZone core class so that it works on PHP versions before v5.1. In my example, I used November 1, 2000 for the date along with a conversion from UTC to Eastern Time ('America/New_York' time zone). Currently (as of 2008), November 1 DOES fall under Daylight Time. However, in the year 2000, November 1 was NOT under Daylight Time. PEAR Date's conversion uses the *current* DST rules to make this Time Zone conversion instead of the DST rules that applied *at that time*. Note that PHP's core DateTime class (added in PHP v5.1) does NOT suffer this limitation. Test script: --------------- <pre> <?php /* ** Run this in PHP v5.1+ to see the discrepency between ** the PEAR Date time zone conversion and PHP v5.1+'s ** core DateTime class. */ $date = new Date('2000-11-01 05:05:00'); $date->setTZById('UTC'); $date->convertTZById('America/New_York'); echo $date->getDate(),"\n"; echo "\n\n"; if ( version_compare(PHP_VERSION, '5.1', '>=') ) { $datet = new DateTime('2000-11-01 05:05:00 UTC'); $datet->setTimeZone(new DateTimeZone('America/New_York')); echo $datet->format('Y-m-d H:i:s'),"\n"; } ?> </pre> Expected result: ---------------- 2000-11-01 00:05:00 2000-11-01 00:05:00 Actual result: -------------- 2000-11-01 01:05:00 2000-11-01 00:05:00

Comments

 [2008-10-25 05:36 UTC] doconnor (Daniel O'Connor)
Take a look at Bug #14770 for the use-php-tz-data The current structure of the package basically just has One Big Array with current timezone data - it's not possible to model past timezone info at the moment.
 [2008-10-25 05:37 UTC] doconnor (Daniel O'Connor)
Oops, you already saw that one :)