lib: Add function `isUnixTimestamp' to the `DateTimeFactory'
Before, the `DateTimeValidator' defined this function. refs #6593
This commit is contained in:
parent
1a4e908461
commit
774db9a7c8
|
@ -76,4 +76,18 @@ class DateTimeFactory implements ConfigAwareFactory
|
|||
{
|
||||
return new DateTime($time, $timeZone !== null ? $timeZone : self::$timeZone);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether a variable is a Unix timestamp
|
||||
*
|
||||
* @param mixed $timestamp
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isUnixTimestamp($timestamp)
|
||||
{
|
||||
return (is_int($timestamp) || ctype_digit($timestamp))
|
||||
&& ($timestamp <= PHP_INT_MAX)
|
||||
&& ($timestamp >= ~PHP_INT_MAX);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue