lib: Add function `isUnixTimestamp' to the `DateTimeFactory'

Before, the `DateTimeValidator' defined this function.

refs #6593
This commit is contained in:
Eric Lippmann 2014-09-03 14:37:33 +02:00
parent 1a4e908461
commit 774db9a7c8
1 changed files with 14 additions and 0 deletions

View File

@ -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);
}
}