ZF-10420: Unexpected behavior with RFC 3339 format
Description
Zend_Date::set() expects ATOM format when RFC 3339 is given...
$date = new Zend_Date();
$rfc_3339 = '2010-09-05T08:30:00.000+03:00';
if (Zend_Date::isDate($rfc_3339, Zend_Date::RFC_3339)) {
$date->set($rfc_3339, Zend_Date::RFC_3339); // invalid date (2010-09-05T08:30:00.000+03:00) operand, ATOM format expected
}
Zend_Date::setTime() fails to set time from RFC 3339 format...
$date = new Zend_Date(); // "5.9.2010 17.57.37"
$rfc_3339 = '2010-09-05T08:30:00.000+03:00';
$date->setTime($rfc_3339);
Zend_Debug::dump("$date"); // string(19) "27.11.2010 17.09.05", expected: "5.9.2010 08.30.00"
Comments
Posted by mmalone (mmalone) on 2010-09-28T06:59:13.000+0000
The problem is that the regex used by Zend_Date for ATOM parsing doesn't allow fractional seconds, even though they're allowed by the standard (see the "time_secfrac" symbol in the BNF: http://tools.ietf.org/html/rfc3339#page-8). Thus, '2010-09-05T08:30:00.000+03:00' doesn't work, but '2010-09-05T08:30:00+03:00' does.
Posted by Kim Blomqvist (kblomqvist) on 2010-09-28T11:37:04.000+0000
Zend_Date source file says that ATOM and RFC_3339 are identical. Is this statement correct?
The solution could be that fractions of a second '.000' is matched (using regexp OR) but ignored, because the smallest time unit supported by Zend_Date is a second.