|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-05-14 17:47 UTC] helixpip at gmail dot com
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
)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 16:00:01 2025 UTC |
Just tested with 5.2.7. The behavior has changed, but it's still not working correctly. The 'scalar' property now returns the original text of the string passed in the <dateTime.iso8601> tags, which is good. The conversion of this string to a timestamp that is stored in the 'timestamp' property still appears to be ignoring the timezone designator, however. Previously, it ignored the timezone designator and assumed local time. Now, it appears to ignore the timezone designator and assume Zulu time. Strtotime() still gives the correct timestamp in all cases. Results of tests: ISO 8601 datetime 20010909T01:46:40Z strtotime yields 1000000000 xmlrpc_decode yields stdClass Object ( [scalar] => 20010909T01:46:40Z [xmlrpc_type] => datetime [timestamp] => 1000000000 ) ISO 8601 datetime 20010909T00:46:40-01 strtotime yields 1000000000 xmlrpc_decode yields stdClass Object ( [scalar] => 20010909T00:46:40-01 [xmlrpc_type] => datetime [timestamp] => 999996400 ) ISO 8601 datetime 2001-09-09T08:46:40+07:00 strtotime yields 1000000000 xmlrpc_decode yields stdClass Object ( [scalar] => 2001-09-09T08:46:40+07:00 [xmlrpc_type] => datetime [timestamp] => 1000025200 ) ISO 8601 datetime 2001-09-08T21:46:40-0400 strtotime yields 1000000000 xmlrpc_decode yields stdClass Object ( [scalar] => 2001-09-08T21:46:40-0400 [xmlrpc_type] => datetime [timestamp] => 999985600 )