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))
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))
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)
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)