From:             helixpip at gmail dot com
Operating system: Windows 2000 
PHP version:      5.2.6
PHP Bug Type:     *XML functions
Bug description:  xmlrpc_decode ignores time zone on iso8601.datetime

Description:
------------
The xmlrpc_decode function does not correctly interpret ISO 8601 timezone
designations when interpreting XML-RPC datetime values passed in
<dateTime.iso8601> tags.  It appears that the time zone designator is
completely ignored and the local time zone is assumed.  (The
xmlrpc_decode_request function shows the same behavior.)

A side effect of this bug is that the 'scalar' and 'timestamp' objects
returned for XML-RPC datetime values will disagree if the object is used is
used in a different time zone than it was created.  Ideally the scalar
property should explicitly be a UTC ISO 8601 datetime value, ending with
the time zone designator 'Z'.

Reproduce code:
---------------
function DecodeDatetime($datetime) {
  print "\nISO 8601 datetime $datetime\n";
  print "strtotime yields " . strtotime($datetime) . "\nxmlrpc_decode
yields ";
  $obj = xmlrpc_decode("<?xml
version=\"1.0\"?><methodResponse><params><param><value><dateTime.iso8601>$datetime</dateTime.iso8601></value></param></params></methodResponse>");
  print_r($obj);
}

DecodeDatetime("20010909T01:46:40Z");
DecodeDatetime("20010909T00:46:40-01");
DecodeDatetime("2001-09-09T08:46:40+07:00");
DecodeDatetime("2001-09-08T21:46:40-0400");

Expected result:
----------------
The ISO 8601 datetime strings tested above are all valid and equivalent  
They all represent the same timestamp as the unix time 1000000000, and
strtotime() function converts them all correctly.  I would expect that the
object returned by xml_rpc decode should, in all four test cases, have the
timestamp property = 1000000000 and have the scalar property as a string
that would convert to 1000000000 if fed to strtotime().

Actual result:
--------------
The xmlrpc_decode function gets them all wrong except for the last one,
which happens to have the same time zone as my test system:

ISO 8601 datetime 20010909T01:46:40Z
strtotime yields 1000000000
xmlrpc_decode yields stdClass Object
(
    [scalar] => 20010909T01:46:40
    [xmlrpc_type] => datetime
    [timestamp] => 1000014400
)

ISO 8601 datetime 20010909T00:46:40-01
strtotime yields 1000000000
xmlrpc_decode yields stdClass Object
(
    [scalar] => 20010909T00:46:40
    [xmlrpc_type] => datetime
    [timestamp] => 1000010800
)

ISO 8601 datetime 2001-09-09T08:46:40+07:00
strtotime yields 1000000000
xmlrpc_decode yields stdClass Object
(
    [scalar] => 20010909T08:46:40
    [xmlrpc_type] => datetime
    [timestamp] => 1000039600
)

ISO 8601 datetime 2001-09-08T21:46:40-0400
strtotime yields 1000000000
xmlrpc_decode yields stdClass Object
(
    [scalar] => 20010908T21:46:40
    [xmlrpc_type] => datetime
    [timestamp] => 1000000000
)

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

Reply via email to