From:             php at michaelho dot com
Operating system: Mac OS X 10.4.10
PHP version:      5.2.4
PHP Bug Type:     Date/time related
Bug description:  Constructing DateTime with TimeZone Indicator invalidates 
DateTimeZone

Description:
------------
When creating a new DateTime with an timezone indicator (e.g. "-0800"), it
seems to ignore any DateTimeZone rules as specified either by the
default_timezone setting OR by an explicit DateTimeZone parameter.

Notice that in the example below, the engine no longer applies
DateTimeZone rules for $bar, even though the engine still lists
"America/Los_Angeles" as $bar's DateTimeZone value.

My guess is that a timezone indicator is passed into the __construct()
method, it will be very difficult for the engine to deduce the correct
DateTimeZone rules to use for that DateTime object, and thus, no rules
should be applied after this point.

If this is the case, then at the very least $bar->getTimezone()->getName()
should return something like 'Undefined' or 'Custom/-0800' or something
like that, to correctly indicate it is no longer using
'America/Los_Angeles' timezone rules.

Reproduce code:
---------------
        date_default_timezone_set('America/Los_Angeles');
        $foo = new DateTime('2007-03-11');
        $bar = new DateTime('2007-03-11T00:00:00-0800');

        print $foo->format(DateTime::ISO8601) . ' - ' .
$foo->getTimezone()->getName() . ' - ' . $foo->format('U') . "\r\n";
        print $bar->format(DateTime::ISO8601) . ' - ' .
$foo->getTimezone()->getName() . ' - ' . $bar->format('U') . "\r\n";

        $foo->setDate(2007, 03, 12);
        $bar->setDate(2007, 03, 12);

        print $foo->format(DateTime::ISO8601) . ' - ' .
$foo->getTimezone()->getName() . ' - ' . $foo->format('U') . "\r\n";
        print $bar->format(DateTime::ISO8601) . ' - ' .
$foo->getTimezone()->getName() . ' - ' . $bar->format('U') . "\r\n";


Expected result:
----------------
2007-03-11T00:00:00-0800 - America/Los_Angeles - 1173600000
2007-03-11T00:00:00-0800 - America/Los_Angeles - 1173600000
2007-03-12T00:00:00-0700 - America/Los_Angeles - 1173682800
2007-03-12T00:00:00-0700 - America/Los_Angeles - 1173682800

Actual result:
--------------
2007-03-11T00:00:00-0800 - America/Los_Angeles - 1173600000
2007-03-11T00:00:00-0800 - America/Los_Angeles - 1173600000
2007-03-12T00:00:00-0700 - America/Los_Angeles - 1173682800
2007-03-12T00:00:00-0800 - America/Los_Angeles - 1173686400

-- 
Edit bug report at http://bugs.php.net/?id=42910&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=42910&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=42910&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=42910&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=42910&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=42910&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=42910&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=42910&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=42910&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=42910&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=42910&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=42910&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=42910&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=42910&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=42910&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=42910&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=42910&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=42910&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=42910&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=42910&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=42910&r=mysqlcfg

Reply via email to