Example #1
0
 def validate(self, value, model_instance):
     value = super(DateProperty, self).validate(value, model_instance)
     
     if isinstance(value, str) or isinstance(value, unicode):
         if not strutil.is_date(value, fmt=self.fmt):
             raise TypeDateError(self.get_label_i18n_key())
         else:
             value = strutil.to_date(value, fmt=self.fmt)
     
     if value and not isinstance(value, self.data_type):
         raise CoreError('Property %s must be a %s',
                           self.name, self.data_type.__name__)
     return value
Example #2
0
 def _get_date_parameter(self, name, fmt, default=None):
     value = self._get_str_parameter(name)
     return strutil.to_date(value, fmt=fmt, default=default)
Example #3
0
 def normalize_value(self, value):
     if isinstance(value, datetime.date):
         return value
     else:
         return strutil.to_date(value, fmt=self.fmt)