from datetime import datetime


def editor_reg_date(identity: dict, global_userinfo: dict):
    """
    Normalize registration date from either oauth or global_userinfo as datetime.date object.
    Parameters
    ----------
    identity : dict
    global_userinfo : dict

    Returns
    -------
    datetime.date
    """
    # Try oauth registration date first.  If it's not valid, try the global_userinfo date
    try:
        reg_date = datetime.strptime(identity["registered"], "%Y%m%d%H%M%S").date()
    except (TypeError, ValueError):
        try:
            reg_date = datetime.strptime(
                global_userinfo["registration"], "%Y-%m-%dT%H:%M:%SZ"
            ).date()
        except (TypeError, ValueError):
            reg_date = None
    return reg_date