def _isValidDate(date_string):
    """
    A helper function used by isValidANSIDate and isValidANSIDatetime to
    check if the date is valid.  The date string is assumed to already be in
    YYYY-MM-DD format.
    """
    from datetime import date
    # Could use time.strptime here and catch errors, but datetime.date below
    # produces much friendlier error messages.
    year, month, day = map(int, date_string.split('-'))
    # This check is needed because strftime is used when saving the date
    # value to the database, and strftime requires that the year be >=1900.
    if year < 1900:
        raise ValidationError, gettext('Year must be 1900 or later.')
    try:
        date(year, month, day)
    except ValueError, e:
        msg = gettext('Invalid date: %s') % gettext(str(e))
        raise ValidationError, msg
dataset/ETHPy150Open AppScale/appscale/AppServer/lib/django-0.96/django/core/validators.py/_isValidDate/original