Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/Helpers/CanValidateDateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ private function isDateFormat(string $format): bool
private function isDateInformation(array $info): bool
{
if ($info['day']) {
return checkdate((int) $info['month'], $info['day'], (int) $info['year']);
return checkdate(
$info['month'] === false ? 1 : $info['month'],
$info['day'],
$info['year'] === false ? 1 : $info['year'],
);
}

return checkdate($info['month'] ?: 1, 1, $info['year'] ?: 1);
Expand Down
5 changes: 5 additions & 0 deletions tests/unit/Validators/DateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ public static function providerForValidInput(): iterable
[new Date('F jS, Y'), 'May 1st, 2017'],
[new Date('Ydm'), 20173112],
[new Date(), '2020-02-29'],
[new Date('d/m'), '15/03'],
[new Date('m/d'), '03/15'],
[new Date('d'), '15'],
[new Date('F j'), 'March 5'],
];
}

Expand All @@ -76,6 +80,7 @@ public static function providerForInvalidInput(): iterable
[new Date('d'), 1],
[new Date('Y-m'), '2014-99'],
[new Date('m'), '99'],
[new Date('d/m'), '31/02'],
];
}
}
Loading