File tree Expand file tree Collapse file tree 2 files changed +7
-7
lines changed
Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Original file line number Diff line number Diff line change 1919
2020import pytz
2121
22- RFC3369 = '%Y-%m-%dT%H:%M:%S.%fZ'
22+ _RFC3339_MICROS = '%Y-%m-%dT%H:%M:%S.%fZ'
2323
2424
2525class Message (object ):
@@ -54,13 +54,13 @@ def timestamp(self):
5454 """Return timestamp from attributes, if passed.
5555
5656 :rtype: datetime
57- :returns: timestamp (in UTC timezone) parsed from RFC 3369 timestamp
57+ :returns: timestamp (in UTC timezone) parsed from RFC 3339 timestamp
5858 :raises: ValueError if timestamp not in ``attributes``, or malformed
5959 """
6060 stamp = self .attributes .get ('timestamp' )
6161 if stamp is None :
6262 raise ValueError ('No timestamp' )
63- return datetime .datetime .strptime (stamp , RFC3369 ).replace (
63+ return datetime .datetime .strptime (stamp , _RFC3339_MICROS ).replace (
6464 tzinfo = pytz .UTC )
6565
6666 @classmethod
Original file line number Diff line number Diff line change @@ -91,13 +91,13 @@ def _to_fail():
9191
9292 def test_timestamp_w_timestamp_in_attributes (self ):
9393 from datetime import datetime
94- import pytz
94+ from pytz import utc
95+ from gcloud .pubsub .message import _RFC3339_MICROS
9596 DATA = b'DEADBEEF'
9697 MESSAGE_ID = b'12345'
9798 TIMESTAMP = '2015-04-10T18:42:27.131956Z'
98- RFC3369 = '%Y-%m-%dT%H:%M:%S.%fZ'
99- naive = datetime .strptime (TIMESTAMP , RFC3369 )
100- timestamp = naive .replace (tzinfo = pytz .utc )
99+ naive = datetime .strptime (TIMESTAMP , _RFC3339_MICROS )
100+ timestamp = naive .replace (tzinfo = utc )
101101 ATTRS = {'timestamp' : TIMESTAMP }
102102 message = self ._makeOne (data = DATA , message_id = MESSAGE_ID ,
103103 attributes = ATTRS )
You can’t perform that action at this time.
0 commit comments