TimeRange: Accept strings in method `validateTime()`
This commit is contained in:
parent
e3a9b56423
commit
3d159fe434
|
@ -119,12 +119,14 @@ class TimeRange implements Iterator
|
||||||
/**
|
/**
|
||||||
* Return whether the given time is within this range of time
|
* 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)
|
public function validateTime($time)
|
||||||
{
|
{
|
||||||
if ($time instanceof DateTime) {
|
if ($time instanceof DateTime) {
|
||||||
$dateTime = $time;
|
$dateTime = $time;
|
||||||
|
} elseif (is_string($time)) {
|
||||||
|
$dateTime = DateTime::createFromFormat('d/m/Y g:i A', $time);
|
||||||
} else {
|
} else {
|
||||||
$dateTime = new DateTime();
|
$dateTime = new DateTime();
|
||||||
$dateTime->setTimestamp($time);
|
$dateTime->setTimestamp($time);
|
||||||
|
|
Loading…
Reference in New Issue