app/Services/CalendarService.php
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;
    }
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;
    }
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 ; }
List all the months in a given year.

@param string $calendar
@param int    $year

@return string[]
List all the months in a given year .