Route the given datetime to the latest time with the hour, minute, second
    before it.

def _floor_to(dt, hour, minute, second):
    """
    Route the given datetime to the latest time with the hour, minute, second
    before it.
    """
    new_dt = dt.replace(hour=hour, minute=minute, second=second)
    if new_dt <= dt:
        return new_dt
    else:
        return new_dt - timedelta(days=1)