From 27f6550b3309948a7618deace1217abe3b815fec Mon Sep 17 00:00:00 2001 From: rlanvin Date: Wed, 9 Dec 2015 14:46:39 +0200 Subject: [PATCH] Adding check for DateTimeInterface to support DateTimeImmutable objects --- src/RRule.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/RRule.php b/src/RRule.php index ea5b4c3..ba86b13 100755 --- a/src/RRule.php +++ b/src/RRule.php @@ -984,7 +984,8 @@ class RRule implements \Iterator, \ArrayAccess, \Countable */ 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 { if ( is_integer($date) ) { $date = \DateTime::createFromFormat('U',$date); @@ -994,7 +995,7 @@ class RRule implements \Iterator, \ArrayAccess, \Countable } } catch (\Exception $e) { throw new \InvalidArgumentException( - 'Failed to parse the date "$date"' + "Failed to parse the date" ); } }