def normalize(obj):
    if obj == None:
        return None
    elif isinstance(obj, datetime.date):
        return extract(obj)
    elif isinstance(obj, basestring):
        try:
            return extract(parse(obj))
        except __HOLE__:
            try:
                return extract(parse_description(obj))
            except ValueError:
                raise ValueError("Cannot parse date or description: " + obj)
    else:
        raise ValueError("Can only normalize dates of type: date, datetime, basestring.")
dataset/ETHPy150Open debrouwere/google-analytics/googleanalytics/utils/date.py/normalize