You are here

function __cronDecodeRule in Elysia Cron 6.2

Same name and namespace in other branches
  1. 5.2 elysia_cron_scheduler.inc \__cronDecodeRule()
  2. 5 elysia_cron_scheduler.inc \__cronDecodeRule()
  3. 6 elysia_cron_scheduler.inc \__cronDecodeRule()
  4. 7 elysia_cron_scheduler.inc \__cronDecodeRule()
2 calls to __cronDecodeRule()
_elysia_cron_next_run in ./elysia_cron_scheduler.inc
__cronDecodeRuleMday in ./elysia_cron_scheduler.inc

File

./elysia_cron_scheduler.inc, line 115

Code

function __cronDecodeRule($rule, $min, $max) {
  if ($rule == '*') {
    return array(
      'n' => array(),
      'd' => 0,
    );
  }
  $result = array(
    'n' => array(),
    'd' => 0,
  );
  foreach (explode(',', $rule) as $token) {
    if (preg_match('/^([0-9]+)-([0-9]+)$/', $token, $r)) {
      $result['n'] = array_merge($result['n'], range($r[1], $r[2]));
    }
    elseif (preg_match('/^\\*\\/([0-9]+)$/', $token, $r)) {
      $result['d'] = $r[1];
    }
    elseif (is_numeric($token)) {
      $result['n'][] = $token;
    }
  }
  sort($result['n']);
  return $result;
}