Home » Web Services » SOAP » Bug #4523
SOAP datetimes interpreted incorrectly when timezone absent
Details
| Submitted | 2005-06-03 23:58 UTC |
|---|---|
| From | cmaddocks at maddocks dot ca |
| Assigned | yunosh |
| Status | Closed |
| Package | SOAP |
| PHP Version | 4.2.2 |
| OS | Windows 2000 SP4 |
| Roadmaps | (Not assigned) |
Comments
[2005-06-03 23:58 UTC] cmaddocks at maddocks dot ca
Description:
------------
The constructor of the SOAP_Type_dateTime class can take an iso-8601 date as a parameter. In the absence of a UTC offset and the 'Z' character (which signifies UTC time) the time is to be interpreted as in some local timezone.
However, the way the class processes the timestamp (SOAP_Type_dateTime::toUnixTime -> SOAP_Type_dateTime::_split, strtotime) effectively interprets all timestamps lacking timezone information as UTC times, not local times.
toUnixtime always returns a UTC-measured timestamp (it tacks a "Z" on the end of its output). Therefore, _split needs to apply the offset of the *local* timezone if none was specified in the timestamp.
Reproduce code:
---------------
Unit testing the SOAP/Type/dateTime.php :
$ts = new SOAP_Type_dateTime( '2001-04-25T09:31:41');
print $ts->toString();
Here's a diff on dateTime.php (based on PEAR::SOAP 0.9.1 beta):
68c68,69
< if ($regs[8] != '' && $regs[8] != 'Z') {
---
> if ($regs[8] == '') $regs[8] = date( "O" );
> if ($regs[8] != 'Z') {
Expected result:
----------------
2001-04-25T09:31:41-0400
(Web server is in UTC-0400)
Actual result:
--------------
2001-04-25T05:31:41-0400