src/LocalDate.php
public static function ofEpochDay(int $epochDay) : LocalDate
    {
        $zeroDay = $epochDay + self::DAYS_0000_TO_1970;
        // Find the march-based year.
        $zeroDay -= 60; // Adjust to 0000-03-01 so leap day is at end of four year cycle.
        $adjust = 0;
        if ($zeroDay < 0) {
            // Adjust negative years to positive for calculation.
            $adjustCycles = \intdiv(($zeroDay + 1), self::DAYS_PER_CYCLE) - 1;
            $adjust = $adjustCycles * 400;
            $zeroDay += -$adjustCycles * self::DAYS_PER_CYCLE;
        }
        $yearEst = \intdiv(400 * $zeroDay + 591, self::DAYS_PER_CYCLE);
        $doyEst = $zeroDay - (365 * $yearEst + \intdiv($yearEst, 4) - \intdiv($yearEst, 100) + \intdiv($yearEst, 400));
        if ($doyEst < 0) {
            // Fix estimate.
            $yearEst--;
            $doyEst = $zeroDay - (365 * $yearEst + \intdiv($yearEst, 4) - \intdiv($yearEst, 100) + \intdiv($yearEst, 400));
        }
        $yearEst += $adjust; // Reset any negative year.
        $marchDoy0 = $doyEst;

        // Convert march-based values back to January-based.
        $marchMonth0 = \intdiv($marchDoy0 * 5 + 2, 153);
        $month = ($marchMonth0 + 2) % 12 + 1;
        $dom = $marchDoy0 - \intdiv($marchMonth0 * 306 + 5, 10) + 1;
        $yearEst += \intdiv($marchMonth0, 10);

        // Check year now we are certain it is correct.
        Field\Year::check($yearEst);

        return new LocalDate($yearEst, $month, $dom);
    }
public static function ofEpochDay(int $epochDay) : LocalDate
    {
        $zeroDay = $epochDay + self::DAYS_0000_TO_1970;
        // Find the march-based year.
        $zeroDay -= 60; // Adjust to 0000-03-01 so leap day is at end of four year cycle.
        $adjust = 0;
        if ($zeroDay < 0) {
            // Adjust negative years to positive for calculation.
            $adjustCycles = \intdiv(($zeroDay + 1), self::DAYS_PER_CYCLE) - 1;
            $adjust = $adjustCycles * 400;
            $zeroDay += -$adjustCycles * self::DAYS_PER_CYCLE;
        }
        $yearEst = \intdiv(400 * $zeroDay + 591, self::DAYS_PER_CYCLE);
        $doyEst = $zeroDay - (365 * $yearEst + \intdiv($yearEst, 4) - \intdiv($yearEst, 100) + \intdiv($yearEst, 400));
        if ($doyEst < 0) {
            // Fix estimate.
            $yearEst--;
            $doyEst = $zeroDay - (365 * $yearEst + \intdiv($yearEst, 4) - \intdiv($yearEst, 100) + \intdiv($yearEst, 400));
        }
        $yearEst += $adjust; // Reset any negative year.
        $marchDoy0 = $doyEst;

        // Convert march-based values back to January-based.
        $marchMonth0 = \intdiv($marchDoy0 * 5 + 2, 153);
        $month = ($marchMonth0 + 2) % 12 + 1;
        $dom = $marchDoy0 - \intdiv($marchMonth0 * 306 + 5, 10) + 1;
        $yearEst += \intdiv($marchMonth0, 10);

        // Check year now we are certain it is correct.
        Field\Year::check($yearEst);

        return new LocalDate($yearEst, $month, $dom);
    }
public static function ofEpochDay ( int $ epochDay ) : LocalDate { $ zeroDay = $ epochDay + self :: DAYS_0000_TO_1970 ; // Find the march-based year. $ zeroDay -= 60 ; // Adjust to 0000-03-01 so leap day is at end of four year cycle. $ adjust = 0 ; if ( $ zeroDay < 0 ) { // Adjust negative years to positive for calculation. $ adjustCycles = \ intdiv ( ( $ zeroDay + 1 ) , self :: DAYS_PER_CYCLE ) - 1 ; $ adjust = $ adjustCycles * 400 ; $ zeroDay += - $ adjustCycles * self :: DAYS_PER_CYCLE ; } $ yearEst = \ intdiv ( 400 * $ zeroDay + 591 , self :: DAYS_PER_CYCLE ) ; $ doyEst = $ zeroDay - ( 365 * $ yearEst + \ intdiv ( $ yearEst , 4 ) - \ intdiv ( $ yearEst , 100 ) + \ intdiv ( $ yearEst , 400 ) ) ; if ( $ doyEst < 0 ) { // Fix estimate. $ yearEst -- ; $ doyEst = $ zeroDay - ( 365 * $ yearEst + \ intdiv ( $ yearEst , 4 ) - \ intdiv ( $ yearEst , 100 ) + \ intdiv ( $ yearEst , 400 ) ) ; } $ yearEst += $ adjust ; // Reset any negative year. $ marchDoy0 = $ doyEst ; // Convert march-based values back to January-based. $ marchMonth0 = \ intdiv ( $ marchDoy0 * 5 + 2 , 153 ) ; $ month = ( $ marchMonth0 + 2 ) % 12 + 1 ; $ dom = $ marchDoy0 - \ intdiv ( $ marchMonth0 * 306 + 5 , 10 ) + 1 ; $ yearEst += \ intdiv ( $ marchMonth0 , 10 ) ; // Check year now we are certain it is correct. Field \ Year :: check ( $ yearEst ) ; return new LocalDate ( $ yearEst , $ month , $ dom ) ; }
Obtains an instance of `LocalDate` from the epoch day count.

The Epoch Day count is a simple incrementing count of days
where day 0 is 1970-01-01. Negative numbers represent earlier days.

@param int $epochDay

@return LocalDate

@throws DateTimeException If the resulting date has a year out of range.
Obtains an instance of LocalDate from the epoch day count .