def isoseconds(time):
    """calculate number of seconds from a given isoformat timestring"""
    if isinstance(time, int):
        return time
    import datetime
    d = 0
    try:
        t = datetime.datetime.strptime(time, '%S').time()
    except ValueError:
        fmt = str(time).count(':') or 2
        if fmt == 1:
            t = datetime.datetime.strptime(time, '%H:%M').time()
        elif fmt == 3:
            t = datetime.datetime.strptime(time, '%d:%H:%M:%S')
            d, t = t.day, t.time()
        else:
            t = datetime.datetime.strptime(time, '%H:%M:%S').time()
    return t.second + 60 * t.minute + 3600 * t.hour + d * 86400
