def jdftime(jde, fmt='%y-%m-%d %H:%M:%S', tz=0, ut=False):
    ''' format a Julian Day to ISO format datetime

    Args:
        jde: time in JDTT
        tz: a integer as timezone, e.g. -8 for UTC-8, 2 for UTC2
        fmt: like strftime but currently only support three format
             %y-%m-%d %H:%M:%S
             %y-%m-%d %H:%M
             %y-%m-%d
        ut: convert to UTC(adjust delta T)

    Return:
        time string in ISO format, e.g. 1984-01-01 23:59:59

        '''

    g = jd2g(jde)
    deltat = deltaT(g[0], g[1]) if ut else 0

    # convert JDE to seconds, then adjust deltat
    utsec = jde * 86400.0 + tz * 3600 - deltat

    jdut = utsec / 86400.0

    # get time in seconds directly to minimize round error
    secs = (utsec + 43200) % 86400

    if fmt == '%y-%m-%d %H:%M':
        secs = int(round(secs / 60.0) * 60.0)
    else:
        secs = int(secs)
    if 86400 == secs:
        jdut = int(jdut) + 0.5
        secs = 0

    y, m, d = jd2g(jdut)
    d = int(d)

    # use integer math hereafter
    H = secs / 3600
    ms = secs % 3600
    M = ms / 60
    S = ms % 60

    # padding zero
    d = '0%d' % d if d < 10 else str(d)
    m = '0%d' % m if m < 10 else str(m)
    H = '0%d' % H if H < 10 else str(H)
    M = '0%d' % M if M < 10 else str(M)
    S = '0%d' % S if S < 10 else str(S)

    if fmt == '%y-%m-%d':
        isodt = '%d-%s-%s' % (y, m, d)
    elif fmt == '%y-%m-%d %H:%M':
        isodt = '%d-%s-%s %s:%s' % (y, m, d, H, M)
    else:
        isodt = '%d-%s-%s %s:%s:%s' % (y, m, d, H, M, S)

    return isodt
 format a Julian Day to ISO format datetime

    Args:
        jde: time in JDTT
        tz: a integer as timezone, e.g. -8 for UTC-8, 2 for UTC2
        fmt: like strftime but currently only support three format
             %y-%m-%d %H:%M:%S
             %y-%m-%d %H:%M
             %y-%m-%d
        ut: convert to UTC(adjust delta T)

    Return:
        time string in ISO format, e.g. 1984-01-01 23:59:59

        
aa.py