Bug #65683 [Com]: Incomplete support of DateTimeImmutable as DateTime(Interface)
Edit report at https://bugs.php.net/bug.php?id=65683&edit=1
ID: 65683
Comment by: phofstetter at sensational dot ch
Reported by: poinsot dot julien at gmail dot com
Summary: Incomplete support of DateTimeImmutable as
DateTime(Interface)
Status: Open
Type: Bug
Package: Date/time related
PHP Version: 5.5.3
Block user comment: N
Private report: N
New Comment:
This has been fixed in 5f09944662e09ea0b3f93cfab8702f188955e68c which is in 5.5.9 and later.
Previous Comments:
------------------------------------------------------------------------
[2013-09-16 17:26:36] poinsot dot julien at gmail dot com
Description:
------------
Actually, DateTimeImmutable is not usable everywhere DateTime is.
Missing support I have found is:
* DatePeriod::__construct where end parameter does not allow a DateTimeImmutable objet as
date_ce_date is used instead of date_ce_interface
* intl extension (see grep -rn php_date_get_date_ce ext/intl for complete list) which use the
function php_date_get_date_ce (so date_ce_date)
Test script:
---------------
var_dump(datefmt_create('fr_FR')->format(date_create_immutable('1970-01-01')));
$start = new DateTimeImmutable('last monday');
var_dump(new DatePeriod($start, DateInterval::createFromDateString('1 day'),
$start->add(DateInterval::createFromDateString('5 days'))));
Expected result:
----------------
string(39) "jeudi 1 janvier 1970 00:00:00 UTC+01:00"
object(DatePeriod)#3 (6) {
...
}
Actual result:
--------------
Warning: IntlDateFormatter::format(): datefmt_format: object must be an instance of DateTime in %s
on %d
Fatal error: Uncaught exception 'Exception' with message 'DatePeriod::__construct():
This constructor accepts either (DateTimeInterface, DateInterval, int) OR (DateTimeInterface,
DateInterval, DateTime) OR (string) as arguments.' in %s:%d
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=65683&edit=1
Thread (8 messages)