-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#797: Add sortable message timestamp #816
#797: Add sortable message timestamp #816
Conversation
Changes Unknown when pulling b0209de on tseaver:797-pubsub-add_sortable_message_timestamp into * on GoogleCloudPlatform:master*. |
|
||
import pytz | ||
|
||
RFC3369 = '%Y-%m-%dT%H:%M:%S.%fZ' |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Changes Unknown when pulling f4c51cf on tseaver:797-pubsub-add_sortable_message_timestamp into * on GoogleCloudPlatform:master*. |
Allows subscribers of timestamping topics to sort messages.
- Ref. correct RFC. - Private - Add '_MICROS' to indicate which format from the sheaf allowed by the RFC. Addresses points 1 and 2 from: #816 (comment). and: #816 (comment)
Rebased after merge of #809. |
Outside of the scope of this PR (just for my understand) what is an example of a naive timestamp being a bad idea? What problems occur? Also note that >>> import datetime
>>> import pytz
>>> now = datetime.datetime.utcnow().replace(tzinfo=pytz.UTC)
>>> now
datetime.datetime(2015, 4, 10, 21, 7, 20, 884712, tzinfo=<UTC>)
>>> now.isoformat()
'2015-04-10T21:07:20.884712+00:00'
>>> datetime.datetime(2015, 4, 10, 21, 7, 20, 0, tzinfo=pytz.UTC).isoformat()
'2015-04-10T21:07:20+00:00'
>>> datetime.datetime(2015, 4, 10, 21, 7, 20, 0).isoformat()
'2015-04-10T21:07:20'
>>> datetime.datetime(2015, 4, 10, 21, 7, 20, 100).isoformat()
'2015-04-10T21:07:20.000100' |
@dhermes any remaining issues? |
It looks like all my issues with the code were addressed. Though I did ask you two questions in my last message. Do you mind answering? LGTM |
Naive datetimes are time-bombs: when created, their zone might be one of a) UTC, b) the "local" zone on the client's machine, or c) the "local" zone on the server. Later code has no way of knowing which zone was intended, making any use of such timestamps for ordering useless. Converting from a UTC timestamp string to a naive datetime discards the information. #818 fixes the issues with using |
…timestamp #797: Add sortable message timestamp
Right, b) and c) are the scary parts. Thanks. |
Based on #809.
Allows subscribers of timestamping topics to sort messages.