PEAR is archived and read-only

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

Home » Web Services » XML_RPC » Bug #5117

XML_RPC needs to encode iso8601.DateTime correctly

Details

Request #5117XML_RPC needs to encode iso8601.DateTime correctly
Submitted2005-08-17 02:51 UTC
Fromjames dot ellis at gmail dot com
Assigneddanielc
StatusClosed
PackageXML_RPC
PHP Version5.0.4
OSAll
Roadmaps(Not assigned)

Comments

[2005-08-17 02:51 UTC] james dot ellis at gmail dot com

Description:
------------
XML_RPC needs to support dateTime.iso8601 encoding. The currently library (1.4) encodes dateTime values as strings.

dateTime is specified here:
http://www.xmlrpc.com/spec
<dateTime.iso8601> date/time 19980717T14:08:55

This can be fixed by adding a simple regex in the string case selector of the switch statement in XML_RPC_encode.

I've employed this in the SF.net phpxmlrpc library to good effect.

This allows date maths to be performed based on the datatype returned rather than having to analyse each value for a matching date type and then doing date maths.

Thanks
James

Test script:
---------------
//note that this hasn't been PEARified, but it should be obvious what is occuring. The regex looks for strings in the format YYYYMMDDTHH:MM:SS

case 'string':
$iso8601_regex = "^[0-9]{8}\T{1}[0-9]{2}\:[0-9]{2}\:[0-9]{2}$";
if(ereg($iso8601_regex, $php_val))
{
//dealing with a dateTime type
$xmlrpc_val->addScalar(trim($php_val), $xmlrpcDateTime);
}
else
{
//normal string type
$xmlrpc_val->addScalar(trim($php_val), $xmlrpcString);
}
break;

Expected result:
----------------
<member><name>date</name>
<value><dateTime.iso8601>20050809T01:33:44</dateTime.iso8601></value>
</member>

//instead of

<member><name>date</name>
<value><string>20050809T01:33:44</string></value>
</member>

Actual result:
--------------
<member><name>date</name>
<value><dateTime.iso8601>20050809T01:33:44</dateTime.iso8601></value>
</member>

[2007-01-04 07:16 UTC] bradsweb2 at hotmail dot com

PHP's date('c') function returns iso8601 dates in the format:
2004-02-12T15:19:21+00:00. Perhaps the regular expression
should be updated to reflect the optional usage of dashes?