TimeRange: Accept strings in method `validateTime()`

This commit is contained in:
Johannes Meyer 2022-06-30 08:40:54 +02:00
parent e3a9b56423
commit 3d159fe434
1 changed files with 3 additions and 1 deletions

View File

@ -119,12 +119,14 @@ class TimeRange implements Iterator
/**
* Return whether the given time is within this range of time
*
* @param int|DateTime $time The timestamp or date and time to check
* @param string|int|DateTime $time The timestamp or date and time to check
*/
public function validateTime($time)
{
if ($time instanceof DateTime) {
$dateTime = $time;
} elseif (is_string($time)) {
$dateTime = DateTime::createFromFormat('d/m/Y g:i A', $time);
} else {
$dateTime = new DateTime();
$dateTime->setTimestamp($time);