def round_down_half_hour(time):
    """
    Rounds a datetime object DOWN to the nearest half hour. So if its 12:15 pm, return datetime at 12:00 pm
    :param time: A datetime object
    """
    if 0 < time.minute < 30:
        return time.replace(minute=0)
    if 30 < time.minute < 59:
        return time.replace(minute=30)
    return time