Example #1
0
 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
Example #2
0
 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
Example #3
0
 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
Example #4
0
 def _to_timestamp(self, datetime_obj):
     obj = utils.parse_to_aware_datetime(datetime_obj)
     return obj.strftime('%Y-%m-%dT%H:%M:%SZ')
Example #5
0
 def _to_timestamp(self, datetime_obj):
     obj = utils.parse_to_aware_datetime(datetime_obj)
     return obj.strftime('%Y-%m-%dT%H:%M:%SZ')
Example #6
0
 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
Example #7
0
 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