Parses a report timestamp in ddhhZ or ddhhmmZ format

    This function assumes the given timestamp is within the hour threshold from current date

def parse_date(date: str, hour_threshold: int = 200):
    """
    Parses a report timestamp in ddhhZ or ddhhmmZ format

    This function assumes the given timestamp is within the hour threshold from current date
    """
    # Format date string
    date = date.strip('Z')
    if len(date) == 4:
        date += '00'
    if not (len(date) == 6 and date.isdigit()):
        return
    # Create initial guess
    now = datetime.utcnow()
    guess = now.replace(day=int(date[0:2]),
                        hour=int(date[2:4]) % 24,
                        minute=int(date[4:6]) % 60,
                        second=0, microsecond=0)
    hourdiff = (guess - now) / timedelta(minutes=1) / 60
    # Handle changing months
    if hourdiff > hour_threshold:
        guess += relativedelta(months=-1)
    elif hourdiff < -hour_threshold:
        guess += relativedelta(months=+1)
    return guess