def quantize_datetime(dt, resolution=None):
<EOL>resolution = int(resolution or <NUM_LIT:6>)<EOL>if hasattr(dt, '<STR_LIT>'):<EOL><INDENT>dt = dt.timetuple()  <EOL><DEDENT>if isinstance(dt, time.struct_time):<EOL><INDENT>dt = list(dt)[:<NUM_LIT:6>]<EOL>dt += [int((dt[<NUM_LIT:5>] - int(dt[<NUM_LIT:5>])) * <NUM_LIT>)]<EOL>dt[<NUM_LIT:5>] = int(dt[<NUM_LIT:5>])<EOL>return datetime.datetime(*(dt[:resolution] + [<NUM_LIT:1>] * max(<NUM_LIT:3> - resolution, <NUM_LIT:0>)))<EOL><DEDENT>if isinstance(dt, tuple) and len(dt) <= <NUM_LIT:9> and all(isinstance(val, (float, int)) for val in dt):<EOL><INDENT>dt = list(dt) + [<NUM_LIT:0>] * (max(<NUM_LIT:6> - len(dt), <NUM_LIT:0>))<EOL>if len(dt) == <NUM_LIT:6> and isinstance(dt[<NUM_LIT:5>], float):<EOL><INDENT>dt = list(dt) + [<NUM_LIT> * (dt[<NUM_LIT:5>] - int(dt[<NUM_LIT:5>]))]<EOL>dt[<NUM_LIT:5>] = int(dt[<NUM_LIT:5>])<EOL><DEDENT>dt = tuple(int(val) for val in dt)<EOL>return datetime.datetime(*(dt[:resolution] + [<NUM_LIT:1>] * max(resolution - <NUM_LIT:3>, <NUM_LIT:0>)))<EOL><DEDENT>return [quantize_datetime(value) for value in dt]<EOL>
Quantize a datetime to integer years, months, days, hours, minutes, seconds or microseconds

    Also works with a `datetime.timetuple` or `time.struct_time` or a 1to9-tuple of ints or floats.
    Also works with a sequenece of struct_times, tuples, or datetimes

    >>> quantize_datetime(datetime.datetime(1970,1,2,3,4,5,6), resolution=3)
    datetime.datetime(1970, 1, 2, 0, 0)

    Notice that 6 is the highest resolution value with any utility
    >>> quantize_datetime(datetime.datetime(1970,1,2,3,4,5,6), resolution=7)
    datetime.datetime(1970, 1, 2, 3, 4, 5)
    >>> quantize_datetime(datetime.datetime(1971,2,3,4,5,6,7), 1)
    datetime.datetime(1971, 1, 1, 0, 0)