public static JulianDate jauTaiutc(double tai1, double tai2) throws JSOFAIllegalParameter, JSOFAInternalError
    {
        boolean big1;
        int i;
        double a1, a2,dats1, ddats, dats2, datd = 0.0, as1, as2, da, d1, d2, fd;
        double utc1, utc2;


        /* Put the two parts of the TAI into big-first order. */
        big1 = ( tai1 >= tai2 );
        if ( big1 ) {
            a1 = tai1;
            a2 = tai2;
        } else {
            a1 = tai2;
            a2 = tai1;
        }

        /* See if the TAI can possibly be in a leap-second day. */
        d1 = a1;
        dats1 = 0.0;
        for ( i = -1; i <= 3; i++ ) {
            d2 = a2 + (double) i;
            Calendar dt;
            dt = jauJd2cal(d1, d2 );
            dats2 = jauDat(dt.iy, dt.im, dt.id, 0.0);
//FIXME            if ( js < 0 ) return -1;
            if ( i == -1 ) dats1 = dats2;
            ddats = dats2 - dats1;
            datd = dats1 / DAYSEC;
            if ( abs(ddats) >= 0.5 ) {

                /* Yes.  Get TAI for the start of the UTC day that */
                /* ends in a leap. */
                JulianDate jd = jauCal2jd(dt.iy, dt.im, dt.id );
                d1 = jd.djm0; d2 = jd.djm1;
                as1 = d1;
                as2 = d2 - 1.0 + datd;

                /* Is the TAI after this point? */
                da = a1 - as1;
                da = da + ( a2 - as2 );
                if ( da > 0 ) {

                    /* Yes:  fraction of the current UTC day that has elapsed. */
                    fd = da * DAYSEC / ( DAYSEC + ddats );

                    /* Ramp TAI-UTC to bring about SOFA's JD(UTC) convention. */
                    datd += ddats * ( fd <= 1.0 ? fd : 1.0 ) / DAYSEC;
                }

                /* Done. */
                break;
            }
            dats1 = dats2;
        }

        /* Subtract the (possibly adjusted) TAI-UTC from TAI to give UTC. */
        a2 -= datd;

        /* Return the UTC result, preserving the TAI order. */
        if ( big1 ) {
            utc1 = a1;
            utc2 = a2;
        } else {
            utc1 = a2;
            utc2 = a1;
        }

        /* TODO Status */
        return new JulianDate(utc1, utc2);

    };