Skip to content

Commit 49e7f7e

Browse files
committed
DateTime::createFromFormat() returns NULL instead of FALSE on error (BC break)
1 parent fcad715 commit 49e7f7e

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/Utils/DateTime.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public function getTimestamp()
117117
* @param string The format the $time parameter should be in
118118
* @param string String representing the time
119119
* @param string|\DateTimeZone desired timezone (default timezone is used if NULL is passed)
120-
* @return static|FALSE
120+
* @return static|NULL
121121
*/
122122
public static function createFromFormat($format, $time, $timezone = NULL)
123123
{
@@ -132,7 +132,7 @@ public static function createFromFormat($format, $time, $timezone = NULL)
132132
}
133133

134134
$date = parent::createFromFormat($format, $time, $timezone);
135-
return $date ? static::from($date) : FALSE;
135+
return $date ? static::from($date) : NULL;
136136
}
137137

138138

tests/Utils/DateTime.createFromFormat.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ Assert::error(function () {
2626
DateTime::createFromFormat('Y-m-d H:i:s', '2050-08-13 11:40:00', 5);
2727
}, Nette\InvalidArgumentException::class, 'Invalid timezone given');
2828

29-
Assert::false(DateTime::createFromFormat('Y-m-d', '2014-10'));
29+
Assert::null(DateTime::createFromFormat('Y-m-d', '2014-10'));

0 commit comments

Comments
 (0)