#42351 [Opn->Asn]: Unable to create dates with years <= -10000 and >= 10000
| From: | jani@php.net | Date: | Mon, 03 Sep 2007 12:37:56 +0000 |
| Subject: | #42351 [Opn->Asn]: Unable to create dates with years <= -10000 and >= 10000 | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-117033@lists.php.net to get a copy of this message | ||
ID: 42351
Updated by: jani@php.net
Reported By: mattsch at gmail dot com
-Status: Open
+Status: Assigned
Bug Type: Date/time related
Operating System: Gentoo Linux 2007.0
-PHP Version: 5.2.4RC2
+PHP Version: 5.2.4
-Assigned To:
+Assigned To: derick
New Comment:
Assigned to the ext/date maintainer.
Previous Comments:
------------------------------------------------------------------------
[2007-08-20 16:17:31] mattsch at gmail dot com
Description:
------------
I am unable to create dates with years <= -10000 and >= 10000. ISO
8601:2004E allows for this under Expanded representations:
http://isotc.iso.org/livelink/livelink/4021199/ISO_8601_2004_E.zip?func=doc.Fetch&nodeid=4021199
ISO 8601:2004(E)
14 © ISO 2004 All rights reserved
4.1.2.4 Expanded representations
If, by agreement, expanded representations are used, the formats shall
be as specified below. The
interchange parties shall agree the additional number of digits in the
time element year. In the examples below
it has been agreed to expand the time element year with two digits.
a) A specific day
Basic format: ±YYYYYMMDD Example: +0019850412
Extended format: ±YYYYY-MM-DD Example: +001985-04-12
b) A specific month
Basic format: ±YYYYY-MM Example: +001985-04
Extended format: not applicable
c) A specific year
Basic format: ±YYYYY Example: +001985
Extended format: not applicable
d) A specific century
Basic format: ±YYY Example: +0019
Extended format: not applicable
Reproduce code:
---------------
Negative year:
<?php
$date = new DateTime('-10000-01-01 00:00:00');
echo $date->format('Y-m-d H:i:s');
?>
Positive year:
<?php
$date = new DateTime('10000-01-01 00:00:00');
echo $date->format('Y-m-d H:i:s');
?>
Expected result:
----------------
Negative year outputs:
-10000-01-01 00:00:00
Positive year outputs:
10000-01-01 00:00:00
Actual result:
--------------
Negative year outputs:
2000-01-01 00:00:00
Positive year outputs:
Fatal error: Uncaught exception 'Exception' with message
'DateTime::__construct(): Failed to parse time string (10000-01-01
00:00:00) at position 12 (0): Double time specification' in /test.php:5
Stack trace:
#0 /test.php(5): DateTime->__construct('10000-01-01 00:...')
#1 {main}
thrown in /test.php on line 5
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=42351&edit=1