public static function expand_time_shortcut($time)
{
$time = str_replace(" ", "", $time);
// empty string can't be a time value
if (strlen($time) == 0) {
return false;
}
// get the parts
$parts = preg_split("/:|\\./", $time);
for ($i = 0; $i < count($parts); $i++) {
switch (strlen($parts[$i])) {
case 0:
return false;
case 1:
$parts[$i] = "0" . $parts[$i];
}
}
// fill unsued parts (eg. 12:00 given but 12:00:00 is needed)
while (count($parts) < 3) {
$parts[] = "00";
}
$return = implode(":", $parts);
$regex23 = '([0-1][0-9])|(2[0-3])';
// regular expression for hours
$regex59 = '([0-5][0-9])';
// regular expression for minutes and seconds
if (!preg_match("/^({$regex23}):({$regex59}):({$regex59})\$/", $return)) {
$return = false;
}
return $return;
}