def METHOD_NAME(date: str) -> datetime:
    # Postgres dates express the timezone in hours while strptime expects
    # the timezone to be expressed in HHmm, thus we need to add 00 as minutes.
    date = f"{date}00"
    if date_with_nanosec.match(date):
        return datetime.strptime(date, POSTGRES_DATE_FORMAT_WITH_NS)
    else:
        return datetime.strptime(date, POSTGRES_DATE_FORMAT_WITHOUT_NS)