Skip to content

Commit

Permalink
Refactored the fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark van Driel authored and Mark van Driel committed Aug 15, 2013
1 parent 1595287 commit 97aaa89
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/Cake/Utility/CakeTime.php
Expand Up @@ -316,6 +316,11 @@ public static function fromString($dateString, $timezone = null) {
return false;
}

$containsDummyDate = (is_string($dateString) && substr($dateString, 0, 10) === '0000-00-00');
if ($containsDummyDate) {
return false;
}

if (is_int($dateString) || is_numeric($dateString)) {
$date = intval($dateString);
} elseif (
Expand All @@ -328,12 +333,7 @@ public static function fromString($dateString, $timezone = null) {
} elseif ($dateString instanceof DateTime) {
$date = (int)$dateString->format('U');
} else {
// workaround for strtotime("0000-00-00 00:00:00") returning -62169955200 on a 64 bit system.
if (substr($dateString, 0, 10) === '0000-00-00') {
$date = false;
} else {
$date = strtotime($dateString);
}
$date = strtotime($dateString);
}

if ($date === -1 || empty($date)) {
Expand Down

0 comments on commit 97aaa89

Please sign in to comment.