PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Date and Time » Date » Bug #4468

BDT DST timezone setting error

Details

Submitted2005-05-29 16:11 UTC
Fromhossy at hossy dot com
Assignedpajoye
StatusNo Feedback
PackageDate
PHP Version4.3.10
OSWindows XP
Roadmaps(Not assigned)

Comments

[2005-05-29 16:11 UTC] hossy at hossy dot com

Description:
------------
When creating a new instance of Date, it initializes 'tz' which is a Date_TimeZone instance. The constructor of Date_TimeZone causes the errors shown in "Actual result."

After looking at the code, I found the problem (see excerpts of TimeZone.php in Reproduce code). The problem is that the constructor assumes because hasdst is true, dstlongname and dstshortname are defined. This might be accurate and just an oversight in the data structure. I'm using TimeZone.php,v 1.6 2004/05/16 12:48:06 which was the file included in the Date v1.4.3 package.

I think this was cuased from the fix in bug #1250: http://pear.php.net/bugs/bug.php?id=1250&edit=2

Reproduce code:
---------------
//$gmdate is a UNIX timestamp for the current GMT date/time.
$tzdate = new Date($gmdate);

Excerpt from TimeZone.php (lines 112-120):
if($_DATE_TIMEZONE_DATA[$id]['hasdst']) {
$this->hasdst = true;
$this->dstlongname = $_DATE_TIMEZONE_DATA[$id]['dstlongname'];
$this->dstshortname = $_DATE_TIMEZONE_DATA[$id]['dstshortname'];
} else {
$this->hasdst = false;
$this->dstlongname = $this->longname;
$this->dstshortname = $this->shortname;
}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Excerpt from TimeZone.php (lines 2973-2977):
'BDT' => array(
'offset' => 21600000,
'longname' => "Bangladesh Time",
'shortname' => 'BDT',
'hasdst' => true ),

Expected result:
----------------
no errors =)

Actual result:
--------------
Notice: Undefined index: dstlongname in C:\Inetpub\hossy.com v2\private_html\Date\TimeZone.php on line 114

Notice: Undefined index: dstshortname in C:\Inetpub\hossy.com v2\private_html\Date\TimeZone.php on line 115

[2005-10-02 17:48 UTC] hossy at hossy dot com

That *is* the latest stable release.