(value)
Format an offset (in seconds) to a string

    The offset should be an integer or float value.

    >>> format_time(0)
    '00:00'
    >>> format_time(20)
    '00:20'
    >>> format_time(3600)
    '01:00:00'
    >>> format_time(10921)
    '03:02:01'
Format an offset (in seconds) to a string
Format an offset ( in seconds ) to a string
def format_time(value):
    """Format an offset (in seconds) to a string

    The offset should be an integer or float value.

    >>> format_time(0)
    '00:00'
    >>> format_time(20)
    '00:20'
    >>> format_time(3600)
    '01:00:00'
    >>> format_time(10921)
    '03:02:01'
    """
    try:
        dt = datetime.utcfromtimestamp(value)
    except (ValueError, TypeError):
        return ""

    if dt.hour == 0:
        return dt.strftime("%M:%S")
    else:
        return dt.strftime("%H:%M:%S")
def format_time ( value ) : try : dt = datetime . utcfromtimestamp ( value ) except ( ValueError , TypeError ) : return "" if dt . hour == 0 : return dt . strftime ( "%M:%S" ) else : return dt . strftime ( "%H:%M:%S" )