Ejemplo n.º 1
0
 public function testCronStringsPartialComplex()
 {
     $this->assertTrue(weathermap_cron_part(0, '0-2'));
     $this->assertTrue(weathermap_cron_part(1, '0-2'));
     $this->assertTrue(weathermap_cron_part(2, '0-2'));
     $this->assertFalse(weathermap_cron_part(3, '0-2'));
     $this->assertFalse(weathermap_cron_part(6, '*/5'));
     $this->assertTrue(weathermap_cron_part(5, '*/5'));
     $this->assertTrue(weathermap_cron_part(15, '*/5'));
 }
function weathermap_check_cron($time, $string)
{
    if ($string == '') {
        return true;
    }
    if ($string == '*') {
        return true;
    }
    if ($string == '* * * * *') {
        return true;
    }
    $localTime = localtime($time, true);
    list($minute, $hour, $weekday, $day, $month) = preg_split('/\\s+/', $string);
    if (weathermap_cron_part($localTime['tm_min'], $minute) && weathermap_cron_part($localTime['tm_hour'], $hour) && weathermap_cron_part($localTime['tm_wday'], $weekday) && weathermap_cron_part($localTime['tm_mday'], $day) && weathermap_cron_part($localTime['tm_mon'] + 1, $month)) {
        return true;
    }
    return false;
}
Ejemplo n.º 3
0
function weathermap_check_cron($time,$string)
{
	if($string == '') return(true);
	if($string == '*') return(true);
	
	$lt = localtime($time, true);
	list($minute,$hour,$wday,$day,$month) = preg_split('/\s+/',$string);
	
	$matched = true;
	
	$matched = $matched && weathermap_cron_part($lt['tm_min'],$minute);
	$matched = $matched && weathermap_cron_part($lt['tm_hour'],$hour);
	$matched = $matched && weathermap_cron_part($lt['tm_wday'],$wday);
	$matched = $matched && weathermap_cron_part($lt['tm_mday'],$day);
	$matched = $matched && weathermap_cron_part($lt['tm_mon']+1,$month);
	
	return($matched);
}