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

Bug #6435 Date_Span resets Timezone
Submitted: 2006-01-07 11:29 UTC
From: lokari at gmx dot biz Assigned: pajoye
Status: Closed Package: Date
PHP Version: 5.1.1 OS: Linux (Debian 3.1)
Roadmaps: (Not assigned)    
Subscription  


 [2006-01-07 11:29 UTC] lokari at gmx dot biz
Description: ------------ When setting a timezone for a DATE-Object, timezone is correctly set. After Using Date_Span with this object, the timezone for the object is resettet to UTC and needs to be reset. Test script: --------------- $dateone->new Date(); $dateone->setTZbyID("UTC"); $dateone->convertTZbyID("Europe/Berlin"); $span = new Date_Span($dateone,$datetwo); print_r($dateone->tz)

Comments

 [2006-04-05 14:07 UTC] danielc (Daniel Convissor)
Another example: <?php include 'Date.php'; $d1 = new Date('2006-03-01'); $d2 = new Date('2006-04-01'); $span = new Date_Span(); echo date('H:i:s O') . "\n"; $span->setFromDateDiff($d1, $d2); echo date('H:i:s O') . "\n"; ?>
 [2006-04-05 14:57 UTC] danielc (Daniel Convissor)
The underlying problem is in Date_TimeZone::inDaylightTime(). If it can't find the TZ environment variable, it goes ahead and sets the timezone to UTC anyway. It should only change the time zone if it can find the timezone in the first place. Here's a patch... --- TimeZone.orig.php 2006-04-05 10:48:47.000000000 -0400 +++ TimeZone.php 2006-04-05 10:56:09.000000000 -0400 @@ -259,9 +259,9 @@ */ function inDaylightTime($date) { - $env_tz = ""; - if(getenv("TZ")) { - $env_tz = getenv("TZ"); + $env_tz = getenv("TZ"); + if(!$env_tz) { + return 0; } putenv("TZ=".$this->id); $ltime = localtime($date->getTime(), true);
 [2006-06-13 18:25 UTC] pajoye (Pierre-Alain Joye)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.