You are here

function __cronDecodeRuleMday in Elysia Cron 6.2

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

File

./elysia_cron_scheduler.inc, line 136

Code

function __cronDecodeRuleMday($rule, $month, $year) {
  $range_from = 1;
  $range_to = $month != 2 ? in_array($month, array(
    4,
    6,
    9,
    11,
  )) ? 30 : 31 : ($year % 4 == 0 ? 29 : 28);
  $r1 = __cronDecodeRule($rule[0], $range_from, $range_to);
  $r2 = __cronDecodeRule($rule[1], $range_from, $range_to);
  if ($r2['d']) {
    for ($i = 0; $i < 7; $i++) {
      if ($i % $r2['d'] == 0) {
        $r2['n'][] = $i;
      }
    }
  }
  if ($r2['n']) {
    $r2['n'] = array_unique($r2['n']);
    $r1['n'] = array_merge($r1['n'], __cronMonDaysFromWeekDays($year, $month, $r2['n']), __cronMonDaysFromWeekDays($year, $month + 1, $r2['n'], 31));

    // Use always "31" and not $range_to, see http://drupal.org/node/1668302
  }
  return $r1;
}