def _type_check_datetime(self, value): try: parse_to_aware_datetime(value) return True except (TypeError, ValueError, AttributeError): # Yes, dateutil can sometimes raise an AttributeError # when parsing timestamps. return False
def _convert_header_value(self, shape, value): if shape.type_name == 'timestamp': datetime_obj = parse_to_aware_datetime(value) timestamp = calendar.timegm(datetime_obj.utctimetuple()) return self._timestamp_rfc822(timestamp) else: return value
def _to_timestamp(self, datetime_obj): obj = utils.parse_to_aware_datetime(datetime_obj) return obj.strftime('%Y-%m-%dT%H:%M:%SZ')
def _convert_timestamp_to_str(self, value): datetime_obj = parse_to_aware_datetime(value) converter = getattr(self, '_timestamp_%s' % self.TIMESTAMP_FORMAT.lower()) final_value = converter(datetime_obj) return final_value
def _convert_timestamp_to_str(self, value): datetime_obj = parse_to_aware_datetime(value) converter = getattr( self, '_timestamp_%s' % self.TIMESTAMP_FORMAT.lower()) final_value = converter(datetime_obj) return final_value