perMonths

@param int   $months
@param mixed $task

@return  ScheduleEvent

@throws \ReflectionException
@throws \Windwalker\DI\Exception\DependencyResolutionException

@since  __DEPLOY_VERSION__
342237
public function perMonths(int $months, $task): ScheduleEvent
    {
        return $this->cron(sprintf('0 0 1 */%d *', $months), $task);
    }
934503
public function setByMonth($month)
    {
        if (!is_integer($month) || $month <= 0 || $month > 12) {
            throw new InvalidArgumentException('Invalid value for BYMONTH');
        }

        $this->byMonth = $month;

        $this->canUseBySetPos = true;

        return $this;
    }
757422
public static function createFromMonth($year, $month)
	    {
	        $year  = self::validateYear($year);
	        $month = self::validateRange($month, 1, 12);

	        return self::createFromDuration($year.'-'.sprintf('%02s', $month).'-01', '1 MONTH');
	    }
74235
private function executeTask($task)
    {
        $this->logger->info("Scheduler: executing task {taskName}...", array(
            'taskName' => $task->getName(),
        ));

        $this->isRunningTask = true;

        $timer = new Timer();

        /**
         * Triggered directly before a scheduled task is executed
         *
         * @param Task $task  The task that is about to be executed
         */
        Piwik::postEvent('ScheduledTasks.execute', array(&$task));

        try {
            $callable = array($task->getObjectInstance(), $task->getMethodName());
            call_user_func($callable, $task->getMethodParameter());
            $message = $timer->__toString();
        } catch (Exception $e) {
            $message = 'ERROR: ' . $e->getMessage();
        }

        $this->isRunningTask = false;

        /**
         * Triggered after a scheduled task is successfully executed.
         *
         * You can use the event to execute for example another task whenever a specific task is executed or to clean up
         * certain resources.
         *
         * @param Task $task The task that was just executed
         */
        Piwik::postEvent('ScheduledTasks.execute.end', array(&$task));

        $this->logger->info("Scheduler: finished. {timeElapsed}", array(
            'timeElapsed' => $timer,
        ));

        return $message;
    }
1255502
public function withMonth(int $month) : ZonedDateTime
    {
        return ZonedDateTime::of($this->localDateTime->withMonth($month), $this->timeZone);
    }
262349
public function create(Task $task): Task
    {
        $response = $this->client->post($this->prepareUrlForKey('add-task'), [], $task->jsonSerialize());
        $responseData = $response->getDecodedBody();

        return new Task($responseData);
    }
1205216
public function daysInMonth($year, $month)
    {
        if ($year < 1) {
            throw new InvalidArgumentException('Year ' . $year . ' is invalid for this calendar');
        } elseif ($month < 1 || $month > 13) {
            throw new InvalidArgumentException('Month ' . $month . ' is invalid for this calendar');
        } elseif ($month == 2) {
            return $this->daysInMonthHeshvan($year);
        } elseif ($month == 3) {
            return $this->daysInMonthKislev($year);
        } elseif ($month == 6) {
            return $this->daysInMonthAdarI($year);
        } else {
            return self::$FIXED_MONTH_LENGTHS[$month];
        }
    }
131190
public static function weekRangeInMonth($month, $year)
    {
        $year  = (int)$year;
        $month = (int)$month;
        if ($year < 1970) { // minimal unix time year 1970
            $month = date("n");
            $year  = date("Y");
        }
        if ($month <= 0 || $month > 12) {
            $month = date("n");
            $year  = date("Y");
        }
        if ($month < 10) {
            $month2 = '0' . $month;
        } else {
            $month2 = $month;
        }
        $weekAwal  = (int)$this->weekNumber($year . '-' . $month2 . '-01');
        $weekAkhir = (int)$this->weekNumber($year . '-' . $month2 . '-' . $this->maxDateInMonth($month, $year));
        /*
          echo $year.'-'.$month2.'-01';
          echo '<br />';
          echo $weekAwal;
          echo '<br />';
          echo $year.'-'.$month2.'-'.$this->getMaxDateInMonth($month,$year);
          echo '<br />';
          echo $weekAkhir;
         */
        if ($weekAwal > $weekAkhir) {
            $weekAwal = 1;
        }
        $a = 0;

        for ($i = $weekAwal; $i <= $weekAkhir; $i++) {
            $a++;
            $weekRange[$a] = (int)$i;
        }

        return $weekRange;
    }
800629
public function getMonth($yearOrStart, $month = null)
    {
        if (!$yearOrStart instanceof \DateTime) {
            $yearOrStart = new \DateTime(sprintf('%s-%s-01', $yearOrStart, $month));
        }

        return $this->getFactory()->createMonth($yearOrStart);
    }
277832
public function singleTaskSchedule(TaskNumber $taskNumber, Schedule ...$schedules)
    {
        $events = \array_map(
            function (Schedule $schedule) {
                return $schedule->events();
            },
            $schedules
        );

        $flattenEvents = \array_merge(...$events);

        if (!isset($flattenEvents[$taskNumber->asArrayIndex()])) {
            $tasksCount = \count($flattenEvents);
            throw new TaskNotExistException("Task with id '{$taskNumber->asInt()}' not found. Last task id is '{$tasksCount}'.");
        }

        $event = $flattenEvents[$taskNumber->asArrayIndex()];

        $schedule = new Schedule();
        $schedule->events([$event]);

        return [$schedule];
    }
1088678
public function daysInMonth($year, $month)
    {
        if ($year === 0) {
            throw new InvalidArgumentException('Year ' . $year . ' is invalid for this calendar');
        } elseif ($month < 1 || $month > 12) {
            throw new InvalidArgumentException('Month ' . $month . ' is invalid for this calendar');
        } elseif ($month === 1 || $month === 3 || $month === 5 || $month === 7 || $month === 8 || $month === 10 || $month === 12) {
            return 31;
        } elseif ($month === 4 || $month === 6 || $month === 9 || $month === 11) {
            return 30;
        } elseif ($this->isLeapYear($year)) {
            return 29;
        } else {
            return 28;
        }
    }
1167796
public function actionMonth()
    {
        $this->stdout("Executing month tasks:" . PHP_EOL, Console::FG_YELLOW);
        $this->trigger(self::EVENT_ON_MONTH_RUN);
        Yii::$app->settings->set('cronLastMonthRun', time(), 'core');
        return ExitCode::OK;
    }
580758
private ProjectCalendar getTaskCalendar(Project.Tasks.Task task)
   {
      ProjectCalendar calendar = null;

      BigInteger calendarID = task.getCalendarUID();
      if (calendarID != null)
      {
         calendar = m_projectFile.getCalendarByUniqueID(Integer.valueOf(calendarID.intValue()));
      }

      return (calendar);
   }
1162324
public function withMonths(int $months) : Period
    {
        if ($months === $this->months) {
            return $this;
        }

        return new Period($this->years, $months, $this->days);
    }
1134654
public function archiveMonthlyAction($year, $month, Request $request = null)
    {
        $action = $this->container->get(MonthlyPostArchiveAction::class);

        return $action($this->resolveRequest($request), $year, $month);
    }
642713
public function plusMonths(int $months) : YearMonth
    {
        if ($months === 0) {
            return $this;
        }

        $month = $this->month + $months - 1;

        $yearDiff = Math::floorDiv($month, 12);
        $month = Math::floorMod($month, 12) + 1;

        $year = $this->year + $yearDiff;

        return new YearMonth($year, $month);
    }
280812
public static function of(int $year, int $month) : YearMonth
    {
        Field\Year::check($year);
        Field\MonthOfYear::check($month);

        return new YearMonth($year, $month);
    }