public static char jauD2tf(final int ndp, final double days, int ihmsf[])
    {
       int nrs, n;
       double rs, rm, rh, a, w, ah, am, as, af;


    /* Handle sign. */
      char sign = (char) ( ( days >= 0.0 ) ? '+' : '-' );

    /* Interval in seconds. */
       a = DAYSEC * abs(days);

    /* Pre-round if resolution coarser than 1s (then pretend ndp=1). */
       if (ndp < 0) {
          nrs = 1;
          for (n = 1; n <= -ndp; n++) {
              nrs *= (n == 2 || n == 4) ? 6 : 10;
          }
          rs = (double) nrs;
          w = a / rs;
          a = rs * dnint(w);
       }

    /* Express the unit of each field in resolution units. */
       nrs = 1;
       for (n = 1; n <= ndp; n++) {
          nrs *= 10;
       }
       rs = (double) nrs;
       rm = rs * 60.0;
       rh = rm * 60.0;

    /* Round the interval and express in resolution units. */
       a = dnint(rs * a);

    /* Break into fields. */
       ah = a / rh;
       ah = dint(ah);
       a -= ah * rh;
       am = a / rm;
       am = dint(am);
       a -= am * rm;
       as = a / rs;
       as = dint(as);
       af = a - as * rs;

    /* Return results. */
       ihmsf[0] = (int) ah;
       ihmsf[1] = (int) am;
       ihmsf[2] = (int) as;
       ihmsf[3] = (int) af;

       return sign;

        }