CI_Calendar::adjust_date PHP Method

adjust_date() public method

This function makes sure that we have a valid month/year. For example, if you submit 13 as the month, the year will increment and the month will become January.
public adjust_date ( $month, $year ) : array
return array
    public function adjust_date($month, $year)
    {
        $date = array();
        $date['month'] = $month;
        $date['year'] = $year;
        while ($date['month'] > 12) {
            $date['month'] -= 12;
            $date['year']++;
        }
        while ($date['month'] <= 0) {
            $date['month'] += 12;
            $date['year']--;
        }
        if (strlen($date['month']) === 1) {
            $date['month'] = '0' . $date['month'];
        }
        return $date;
    }