def calc24hr(hour, period):
    """Converts given hour to 24hr format"""
    if not hour:
        return None
    hour = int(hour)
    if period == "pm" and hour <= 12:
        hour = 0 if hour == 12 else hour + 12
    if hour > 23:
        hour = 8
    return hour