Example #1
0
 def set_min_date(self, date):
     if date:
         if type(date) == datetime.date:
             self.minDate = date
         elif type(date) == datetime.datetime:
             self.minDate = date.date()
         else:
             self.minDate = (datetime.date.today() - 
                         datetime.timedelta(self.minYearDelta * 365))
     else:
         self.minDate = (datetime.date.today() - 
                 datetime.timedelta(self.minYearDelta * 365))
Example #2
0
 def set_max_date(self, date):
     if date:
         if type(date) == datetime.date:
             self.maxDate = date
         elif type(date) == datetime.datetime:
             self.maxDate = date.date()
         else:
             self.maxDate = (datetime.date.today() + 
                     datetime.timedelta(self.maxYearDelta * 365))
     else:
         self.maxDate = (datetime.date.today() + 
                 datetime.timedelta(self.maxYearDelta * 365))
Example #3
0
 def _toFieldValue(self, value):
     dates = []
     for token in itertools.chain(
             *[line.split("\n") for line in value.split(",")]):
         token = token.strip()
         if not token:
             continue
         try:
             date = parseDatetimetz(token)
             dates.append(date.date())
         except (DateTimeError, ValueError, IndexError), v:
             raise ConversionError(
                 _("Invalid date: $value", mapping={"value": token}), v)
Example #4
0
 def _toFieldValue(self, value):
     dates = []
     for token in itertools.chain(*[
         line.split("\n") for line in value.split(",")]):
         token = token.strip()
         if not token:
             continue
         try:
             date = parseDatetimetz(token)
             dates.append(date.date())
         except (DateTimeError, ValueError, IndexError), v:
             raise ConversionError(
                 _("Invalid date: $value",
                   mapping={"value": token}), v)