mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-29 08:44:10 +02:00
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);
|
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…
x
Reference in New Issue
Block a user