You are here

function _cronDecodeRuleMday in Elysia Cron 7.2

Helper function for _elysia_cron_next_run().

1 call to _cronDecodeRuleMday()
_elysia_cron_next_run in ./elysia_cron_scheduler.inc
Helper function for cron run schedule.

File

./elysia_cron_scheduler.inc, line 164
Schedules cron runs.

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']);

    // Use always "31" and not $range_to, see http://drupal.org/node/1668302.
    $r1['n'] = array_merge($r1['n'], _cronMonDaysFromWeekDays($year, $month, $r2['n']), _cronMonDaysFromWeekDays($year, $month + 1, $r2['n'], 31));
  }
  return $r1;
}