protected function yToJd($year)
    {
        $div19 = (int) (($year - 1) / 19);
        $mod19 = ($year - 1) % 19;

        $months      = 235 * $div19 + 12 * $mod19 + (int) ((7 * $mod19 + 1) / 19);
        $parts       = 204 + 793 * ($months % 1080);
        $hours       = 5 + 12 * $months + 793 * (int) ($months / 1080) + (int) ($parts / 1080);
        $conjunction = 1080 * ($hours % 24) + ($parts % 1080);
        $julian_day  = 1 + 29 * $months + (int) ($hours / 24);

        if ($conjunction >= 19440 ||
            $julian_day % 7 === 2 && $conjunction >= 9924 && !$this->isLeapYear($year) ||
            $julian_day % 7 === 1 && $conjunction >= 16789 && $this->isLeapYear($year - 1)
        ) {
            $julian_day++;
        }

        // The actual year start depends on the day of the week
        return $julian_day + self::$ROSH_HASHANAH[$julian_day % 7];
    }