Req #53831 [NEW]: DateInterval constructor does not handle valid ISO 8601 strings
| From: | pallinger at dsd dot sztaki dot hu | Date: | Mon, 24 Jan 2011 17:41:20 +0000 |
| Subject: | Req #53831 [NEW]: DateInterval constructor does not handle valid ISO 8601 strings | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-158145@lists.php.net to get a copy of this message | ||
From:
Operating system: ubuntu linux 10.10
PHP version: 5.3.5
Package: Date/time related
Bug Type: Feature/Change Request
Bug description:DateInterval constructor does not handle valid ISO 8601 strings
Description:
------------
---
From manual page: http://www.php.net/dateinterval.construct
---
The documentation says that "Each duration period is represented by an
integer value followed by a period designator.", however, the ISO 8601
allows non-integer values for the last number
(http://en.wikipedia.org/wiki/ISO_8601#Durations).
This is quite important if I want to parse XML data which contains
millisecond-precision durations, as the seconds will surely not be
integers.
Test script:
---------------
<?php
var_dump(new DateInterval('PT1.1S'));
?>
Expected result:
----------------
Should print out a valid DateInterval object, eg.:
object(DateInterval)#1 (8) {
["y"]=>
int(0)
["m"]=>
int(0)
["d"]=>
int(0)
["h"]=>
int(0)
["i"]=>
int(0)
["s"]=>
float(1.1)
["invert"]=>
int(0)
["days"]=>
bool(false)
}
It could also include a millisecond/microsecond/nanosecond field to
accomodate additional precision. However, if the durations that are stored
are still integers, it would be difficult to handle durations like "P0.5Y".
Actual result:
--------------
PHP Fatal error: Uncaught exception 'Exception' with message
'DateInterval::__construct(): Unknown or bad format (PT1.1S)' in -:1
Stack trace:
#0 -(1): DateInterval->__construct('PT1.1S')
#1 {main}
thrown in - on line 1
--
Edit bug report at http://bugs.php.net/bug.php?id=53831&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=53831&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=53831&r=trysnapshot53
Try a snapshot (trunk): http://bugs.php.net/fix.php?id=53831&r=trysnapshottrunk
Fixed in SVN: http://bugs.php.net/fix.php?id=53831&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=53831&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=53831&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=53831&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=53831&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=53831&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=53831&r=support
Expected behavior: http://bugs.php.net/fix.php?id=53831&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=53831&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=53831&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=53831&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=53831&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=53831&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=53831&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=53831&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=53831&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=53831&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=53831&r=mysqlcfg