Exemple #1
0
 def to_python(self, value):
     if value is None:
         return value
     if isinstance(value, datetime.datetime):
         return value.date()
     if isinstance(value, datetime.date):
         return value
     validators.isValidANSIDate(value, None)
     try:
         return datetime.date(*time.strptime(value, '%Y-%m-%d')[:3])
     except ValueError:
         raise validators.ValidationError, _('Enter a valid date in YYYY-MM-DD format.')
Exemple #2
0
 def to_python(self, value):
     if value is None:
         return value
     if isinstance(value, datetime.datetime):
         return value.date()
     if isinstance(value, datetime.date):
         return value
     validators.isValidANSIDate(value, None)
     try:
         return datetime.date(*time.strptime(value, '%Y-%m-%d')[:3])
     except ValueError:
         raise validators.ValidationError, _('Enter a valid date in YYYY-MM-DD format.')
 def isValidDate(self, field_data, all_data):
     try:
         validators.isValidANSIDate(field_data, all_data)
     except validators.ValidationError as e:
         raise validators.CriticalValidationError(e.messages)
 def isValidDate(self, field_data, all_data):
     try:
         validators.isValidANSIDate(field_data, all_data)
     except validators.ValidationError, e:
         raise validators.CriticalValidationError, e.messages