List all the months in a given year.

@param string $calendar
@param int    $year

@return string[]
556880
public function calendarMonthsInYear(string $calendar, int $year): array
    {
        $date          = new Date($calendar . ' ' . $year);
        $calendar_date = $date->minimumDate();
        $month_numbers = range(1, $calendar_date->monthsInYear());
        $month_names   = [];

        foreach ($month_numbers as $month_number) {
            $calendar_date->day   = 1;
            $calendar_date->month = $month_number;
            $calendar_date->setJdFromYmd();

            if ($month_number === 6 && $calendar_date instanceof JewishDate && !$calendar_date->isLeapYear()) {
                // No month 6 in Jewish non-leap years.
                continue;
            }

            if ($month_number === 7 && $calendar_date instanceof JewishDate && !$calendar_date->isLeapYear()) {
                // Month 7 is ADR in Jewish non-leap years (and ADS in others).
                $mon = 'ADR';
            } else {
                $mon = $calendar_date->format('%O');
            }

            $month_names[$mon] = $calendar_date->format('%F');
        }

        return $month_names;
    }
308572
public function all()
    {
        $calendars = PublicCalendar::get();
        $events = new ArrayList();
        foreach ($calendars as $cal) {
            $events->merge($cal->Events());
        }


        $eventsArr = $events->toNestedArray();

        //Debug::dump($eventsArr);
        //return false;

        $ics = new ICSExport($eventsArr);
        return $this->output($ics, 'all');
    }
686901
public function getHorarios($year, $term)
    {
        $classes = $this->getTurmasVirtuais($year, $term);

        $shifts = [];
        $shifts['M'][1]['hora'] = '07:00 - 07:45';
        $shifts['M'][2]['hora'] = '07:45 - 08:30';
        $shifts['M'][3]['hora'] = '08:50 - 09:35';
        $shifts['M'][4]['hora'] = '09:35 - 10:20';
        $shifts['M'][5]['hora'] = '10:30 - 11:15';
        $shifts['M'][6]['hora'] = '11:15 - 12:00';

        $shifts['V'][1]['hora'] = '13:00 - 13:45';
        $shifts['V'][2]['hora'] = '13:45 - 14:30';
        $shifts['V'][3]['hora'] = '14:40 - 15:25';
        $shifts['V'][4]['hora'] = '15:25 - 16:10';
        $shifts['V'][5]['hora'] = '16:30 - 17:15';
        $shifts['V'][6]['hora'] = '17:15 - 18:00';

        $shifts['N'][1]['hora'] = '19:00 - 19:45';
        $shifts['N'][2]['hora'] = '19:45 - 20:30';
        $shifts['N'][3]['hora'] = '20:40 - 21:25';
        $shifts['N'][4]['hora'] = '21:25 - 22:10';

        $schedule = [];
        $schedule[1] = $shifts;
        $schedule[2] = $shifts;
        $schedule[3] = $shifts;
        $schedule[4] = $shifts;
        $schedule[5] = $shifts;
        $schedule[6] = $shifts;
        $schedule[7] = $shifts;

        // Insere os dados da aula (2M12, 3V34) no local apropriado no array.
        foreach ($classes as $class) {
            $horarios = explode(' / ', $class['horarios_de_aula']);

            foreach ($horarios as $horario) {
                // As vezes disciplinas não tem horários. Isso resulta em uma String vazia.
                if ($horario != '') {
                    $day = $horario[0];
                    $shift = $horario[1];

                    $stringSize = strlen($horario);

                    for ($i = 2; $i < $stringSize; $i++) {
                        $slot = $horario[$i];
                        $schedule[$day][$shift][$slot]['aula'] = $class;
                    }
                }
            }
        }

        return $schedule;
    }
1218319
public function ymdToJd($year, $month, $day)
    {
        if ($month < 1 || $month > $this->monthsInYear()) {
            throw new InvalidArgumentException('Month ' . $month . ' is invalid for this calendar');
        }

        $epbase = $year - (($year >= 0) ? 474 : 473);
        $epyear = 474 + $this->mod($epbase, 2820);

        return
            $day +
            (($month <= 7) ? (($month - 1) * 31) : ((($month - 1) * 30) + 6)) +
            (int) ((($epyear * 682) - 110) / 2816) +
            ($epyear - 1) * 365 +
            (int) (floor($epbase / 2820)) * 1029983 +
            $this->jdStart() - 1;
    }
862672
public function renderMonth($year, $month)
    {
        $monthClass   = sprintf('bm-calendar-month-%02d', $month);
        $yearClass    = sprintf('bm-calendar-year-%04d', $year);

        $month = $this->calendar->getMonth($year, $month);
        $days  = $this->calendar->getDays($month);

        $column = 0;

        $output  = '<table class="bm-calendar ' . $monthClass . ' ' . $yearClass .'">';

        $output .= $this->monthTitle($month);

        $output .= '<tbody>';

        $output .= '<tr>';

        $blankCells = ($month->startDay() - $this->startDay + 7) % 7;

        while ($column < $blankCells) {
            $output .= '<td class="bm-calendar-empty"></td>';
            $column++;
        }

        foreach ($days as $day) {
            if (1 !== $day->value() && 0 === $column) {
                $output .= '</tr><tr>';
            }

            $output .= $this->renderDay($day, $column);

            $column = ($column + 1) % 7;
        }

        while ($column < 7) {
            $output .= '<td class="bm-calendar-empty"></td>';
            $column++;
        }

        $output .= '</tr>';

        $output .= '</tbody>';

        $output .= '</table>';

        return $output;
    }
19927
public static function year($year = null)
	{
		$from = DateTime::create(1, 1, $year);
		$till = $from->copy()->addYears(1)->addDays(-1);
		return new Calendar($from, $till);
	}
1090218
public function monthArray($begin, $end, $year = '')
    {
        if (empty($year)) {
            $year = date('Y');
        }
        $dateArray = array();
        for ($i = $begin; $i <= $end; ++$i) {
            $dateArray[] = $i;
        }
        return $dateArray;
    }
386969
private static function jdMonthNameCalendar(CalendarInterface $calendar, $julian_day, $months)
    {
        list(, $month) = $calendar->jdToYmd($julian_day);

        return $months[$month];
    }
16698
public function getHolidaysByYear($year)
    {
        $easter = $this->getEasterDates($year);

        $greatPrayerDay = clone $easter['easterSunday'];
        $greatPrayerDay->modify('+26 days');

        $holidays = array(
            '01-01' => $this->createData('Nytår'),
            '12-25' => $this->createData('1. Juledag'),
            '12-26' => $this->createData('2. Juledag'),

            // Variable dates
            $easter['maundyThursday']->format(self::DATE_FORMAT)  => $this->createData('Skærtorsdag'),
            $easter['goodFriday']->format(self::DATE_FORMAT)      => $this->createData('Langfredag'),
            $easter['easterSunday']->format(self::DATE_FORMAT)    => $this->createData('Påskedag'),
            $easter['easterMonday']->format(self::DATE_FORMAT)    => $this->createData('2. Påskedag'),
            $greatPrayerDay->format(self::DATE_FORMAT)            => $this->createData('Store Bededag'),
            $easter['ascensionDay']->format(self::DATE_FORMAT)    => $this->createData('Kristi Himmelfartsdag'),
            $easter['pentecostSunday']->format(self::DATE_FORMAT) => $this->createData('Pinsedag'),
            $easter['pentecostMonday']->format(self::DATE_FORMAT) => $this->createData('2. Pinsedag')
        );

        return $holidays;
    }
325026
public static function getAll() : array
    {
        $months = [];

        for ($month = Month::JANUARY; $month <= Month::DECEMBER; $month++) {
            $months[] = Month::get($month);
        }

        return $months;
    }
653498
private String[] getDays(int year, int month) {
        Calendar cal = Calendar.getInstance();
        cal.set(year, month, 1);
        int dayNum = cal.getActualMaximum(Calendar.DAY_OF_MONTH);

        String[] days = new String[dayNum];
        for (int i = 0; i < dayNum; i++) {
            days[i] = String.valueOf(i + 1);
        }

        return days;
    }
850114
public function getHolidaysForMonth($year, $month, $region, DateTimeZone $timezone = null)
    {
        $holidayList = $this->holidayCalculator->calculateHolidaysForYear($year, $region, $timezone);
        $date = new DateTime(sprintf('%s-%s-01', $year, $month), $timezone);
        $lastDayOfMonth = (int) $date->format('t');
        $filteredHolidays = (new IncludeTimespanFilter())->filter($holidayList, [
            IncludeTimespanFilter::PARAM_FIRST_DAY => $date,
            IncludeTimespanFilter::PARAM_LAST_DAY => new DateTime(sprintf('%s-%s-%s', $year, $month, $lastDayOfMonth), $timezone),
        ]);

        return $filteredHolidays;
    }
352278
public function monthFirstChildQuery(int $year1 = -1, int $year2 = -1): Builder
    {
        $first_child_subquery = DB::table('link')
            ->join('dates', static function (JoinClause $join): void {
                $join
                    ->on('d_gid', '=', 'l_to')
                    ->on('d_file', '=', 'l_file')
                    ->where('d_julianday1', '<>', 0)
                    ->whereIn('d_month', ['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC']);
            })
            ->where('l_file', '=', $this->tree->id())
            ->where('l_type', '=', 'CHIL')
            ->select(['l_from AS family_id', DB::raw('MIN(d_julianday1) AS min_birth_jd')])
            ->groupBy('family_id');

        $query = DB::table('link')
            ->join('dates', static function (JoinClause $join): void {
                $join
                    ->on('d_gid', '=', 'l_to')
                    ->on('d_file', '=', 'l_file');
            })
            ->joinSub($first_child_subquery, 'subquery', static function (JoinClause $join): void {
                $join
                    ->on('family_id', '=', 'l_from')
                    ->on('min_birth_jd', '=', 'd_julianday1');
            })
            ->where('link.l_file', '=', $this->tree->id())
            ->where('link.l_type', '=', 'CHIL')
            ->select(['d_month', DB::raw('COUNT(*) AS total')])
            ->groupBy(['d_month']);

        if ($year1 >= 0 && $year2 >= 0) {
            $query->whereBetween('d_year', [$year1, $year2]);
        }

        return $query;
    }
1149128
public function getHolidaysByYear($year)
    {
        $easter = $this->getEasterDates($year);

        $mothersDay = date('m-d', strtotime('second Sunday of May '. $year));

        $holidays = array(
            '01-01' => $this->createData('Jaunais Gads'),
            '05-01' => $this->createData('Darba svētki'),
            '05-04' => $this->createData('Latvijas Republikas Neatkarības atjaunošanas diena'),
            $mothersDay => $this->createData('Mātes diena'),
            '06-23' => $this->createData('Līgo Diena'),
            '06-24' => $this->createData('Jāņi'),
            '11-18' => $this->createData('Latvijas Republikas proklamēšanas diena'),
            '12-24' => $this->createData('Ziemassvētku vakars'),
            '12-25' => $this->createData('Ziemassvētki'),
            '12-26' => $this->createData('Otrie Ziemassvētki'),
            '12-31' => $this->createData('Vecgada vakars'),

            // Easter dates
            $easter['goodFriday']->format(self::DATE_FORMAT) => $this->createData('Lielā Piektdiena'),
            $easter['easterSunday']->format(self::DATE_FORMAT) => $this->createData('Lieldienas'),
            $easter['easterMonday']->format(self::DATE_FORMAT) => $this->createData('Otrās Lieldienas'),
        );

        return $holidays;
    }
1023287
public static function nextPeriod($period, $year, $number)
    {
        $maxPeriod = 12 / $period;
        if ($number < $maxPeriod) {
            return array('year' => $year, 'number' => ($number + 1));
        } else {
            return array('year' => ($year + 1), 'number' => 1);
        }
    }
210461
private void getYearlyAbsoluteDates(Calendar calendar, List<Date> dates)
   {
      long startDate = calendar.getTimeInMillis();
      calendar.set(Calendar.DAY_OF_MONTH, 1);
      calendar.set(Calendar.MONTH, NumberHelper.getInt(m_monthNumber) - 1);
      int requiredDayNumber = NumberHelper.getInt(m_dayNumber);

      while (moreDates(calendar, dates))
      {
         int useDayNumber = requiredDayNumber;
         int maxDayNumber = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
         if (useDayNumber > maxDayNumber)
         {
            useDayNumber = maxDayNumber;
         }

         calendar.set(Calendar.DAY_OF_MONTH, useDayNumber);
         if (calendar.getTimeInMillis() < startDate)
         {
            calendar.add(Calendar.YEAR, 1);
         }

         dates.add(calendar.getTime());
         calendar.set(Calendar.DAY_OF_MONTH, 1);
         calendar.add(Calendar.YEAR, 1);
      }
   }
1219801
public static function getMonthEnd($month = -1, $year = -1)
    {
        if ($month == -1) {
            $month = date("n");
        }
        if ($year == -1) {
            $year = date("Y");
        }

        //gets the number of days in the actual month
        $tempTime = mktime(0, 0, 0, $month, 1, $year);
        $tempTime = date("t", $tempTime);

        return mktime(23, 59, 59, $month, $tempTime, $year);
    }