src/LocalDate.php
public static function ofYearDay(int $year, int $dayOfYear) : LocalDate
    {
        Field\Year::check($year);
        Field\DayOfYear::check($dayOfYear, $year);

        $isLeap = Field\Year::isLeap($year);

        $monthOfYear = Month::of(\intdiv($dayOfYear - 1, 31) + 1);
        $monthEnd = $monthOfYear->getFirstDayOfYear($isLeap) + $monthOfYear->getLength($isLeap) - 1;

        if ($dayOfYear > $monthEnd) {
            $monthOfYear = $monthOfYear->plus(1);
        }

        $dayOfMonth = $dayOfYear - $monthOfYear->getFirstDayOfYear($isLeap) + 1;

        return LocalDate::of($year, $monthOfYear->getValue(), $dayOfMonth);
    }
public static function ofYearDay(int $year, int $dayOfYear) : LocalDate
    {
        Field\Year::check($year);
        Field\DayOfYear::check($dayOfYear, $year);

        $isLeap = Field\Year::isLeap($year);

        $monthOfYear = Month::of(\intdiv($dayOfYear - 1, 31) + 1);
        $monthEnd = $monthOfYear->getFirstDayOfYear($isLeap) + $monthOfYear->getLength($isLeap) - 1;

        if ($dayOfYear > $monthEnd) {
            $monthOfYear = $monthOfYear->plus(1);
        }

        $dayOfMonth = $dayOfYear - $monthOfYear->getFirstDayOfYear($isLeap) + 1;

        return LocalDate::of($year, $monthOfYear->getValue(), $dayOfMonth);
    }
public static function ofYearDay ( int $ year , int $ dayOfYear ) : LocalDate { Field \ Year :: check ( $ year ) ; Field \ DayOfYear :: check ( $ dayOfYear , $ year ) ; $ isLeap = Field \ Year :: isLeap ( $ year ) ; $ monthOfYear = Month :: of ( \ intdiv ( $ dayOfYear - 1 , 31 ) + 1 ) ; $ monthEnd = $ monthOfYear -> getFirstDayOfYear ( $ isLeap ) + $ monthOfYear -> getLength ( $ isLeap ) - 1 ; if ( $ dayOfYear > $ monthEnd ) { $ monthOfYear = $ monthOfYear -> plus ( 1 ) ; } $ dayOfMonth = $ dayOfYear - $ monthOfYear -> getFirstDayOfYear ( $ isLeap ) + 1 ; return LocalDate :: of ( $ year , $ monthOfYear -> getValue ( ) , $ dayOfMonth ) ; }
Obtains an instance of `LocalDate` from a year and day-of-year.

@param int $year      The year, from MIN_YEAR to MAX_YEAR.
@param int $dayOfYear The day-of-year, from 1 to 366.

@return LocalDate

@throws DateTimeException If either value is not valid.
Obtains an instance of LocalDate from a year and day - of - year .