1
0
mirror of https://github.com/rlanvin/php-rrule.git synced 2025-02-20 09:54:16 +01:00

Adding check for DateTimeInterface to support DateTimeImmutable objects

This commit is contained in:
rlanvin 2015-12-09 14:46:39 +02:00
parent 660012a2f1
commit 27f6550b33

View File

@ -984,7 +984,8 @@ class RRule implements \Iterator, \ArrayAccess, \Countable
*/ */
static public function parseDate($date) static public function parseDate($date)
{ {
if ( ! $date instanceof \DateTime ) { // DateTimeInterface is only on PHP 5.5+, and includes DateTimeImmutable
if ( ! $date instanceof \DateTime && ! $date instanceof \DateTimeInterface ) {
try { try {
if ( is_integer($date) ) { if ( is_integer($date) ) {
$date = \DateTime::createFromFormat('U',$date); $date = \DateTime::createFromFormat('U',$date);
@ -994,7 +995,7 @@ class RRule implements \Iterator, \ArrayAccess, \Countable
} }
} catch (\Exception $e) { } catch (\Exception $e) {
throw new \InvalidArgumentException( throw new \InvalidArgumentException(
'Failed to parse the date "$date"' "Failed to parse the date"
); );
} }
} }