code: def _cast_to_type(self, value):
          
          if isinstance(value, datetime.datetime):
              return value
          if isinstance(value, datetime.date):
              value = datetime.datetime(value.year, value.month, value.day)
              return value
          try:
              value = date_parser(value)
              return value
          except ValueError:
              self.fail('invalid', value=value)
docs: Convert the value to a datetime and raise error on failures