private static function iauJd2cal($dj1, $dj2, &$iy, &$im, &$id, &$fd)
    {
        /* Minimum and maximum allowed JD */
        $DJMIN = -68569.5;
        $DJMAX = 1e9;
        $jd;
        $l;
        $n;
        $i;
        $k;
        $dj;
        $d1;
        $d2;
        $f1;
        $f2;
        $f;
        $d;
        /* Verify date is acceptable. */
        $dj = $dj1 + $dj2;
        if ($dj < $DJMIN || $dj > $DJMAX) {
            return -1;
        }
        /* Copy the date, big then small, and re-align to midnight. */
        if ($dj1 >= $dj2) {
            $d1 = $dj1;
            $d2 = $dj2;
        } else {
            $d1 = $dj2;
            $d2 = $dj1;
        }
        $d2 -= 0.5;
        /* Separate day and fraction. */
        $f1 = fmod($d1, 1.0);
        $f2 = fmod($d2, 1.0);
        $f  = fmod($f1 + $f2, 1.0);
        if ($f < 0.0) {
            $f += 1.0;
        }
        $d  = floor($d1 - $f1) + floor($d2 - $f2) + floor($f1 + $f2 - $f);
        $jd = floor($d) + 1;
        /* Express day in Gregorian calendar. */
        // Integer division parts of this block was modified in the PHP translation
        $l = $jd + 68569;
        $n = intval((4 * $l) / 146097);
        $l -= intval((146097 * $n + 3) / 4);
        $i = intval((4000 * ($l + 1)) / 1461001);
        $l -= ((1461 * $i) / 4) - 31;
        $k  = intval((80 * $l) / 2447);
        $id = round($l - (2447 * $k) / 80);
        $l  = intval($k / 11);
        $im = (int)($k + 2 - 12 * $l);
        $iy = (int)(100 * ($n - 49) + $i + $l);
        $fd = $f;

        return 0;
    }