def truncate_microsecond(dt, measure):
    """
    Truncate by microsecond

    >>> dt = datetime(2000, 1, 1, 12, 30, 38, 12345)
    >>> truncate_microsecond(dt, 100)
    datetime.datetime(2000, 1, 1, 12, 30, 38, 12300)
    """
    d = datetime(
        dt.year, dt.month, dt.day, tzinfo=dt.tzinfo)  # local zero for seconds
    seconds = total_seconds(dt - d) * 1000000 // measure * measure / 1000000
    return dt.utcfromtimestamp(seconds + utctotimestamp(d))
dataset/ETHPy150Open blaze/blaze/blaze/compute/pydatetime.py/truncate_microsecond/original