Created
July 9, 2010 18:26
-
-
Save soundkitchen/469832 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> import datetime | |
>>> import pytz | |
>>> | |
>>> tz_tokyo = pytz.timezone('Asia/Tokyo') | |
>>> | |
>>> now = datetime.datetime.now() | |
>>> now.strftime('%Y-%m-%dT%H:%M:%S%z') | |
'2010-07-10T03:31:34' | |
>>> | |
>>> now = tz_tokyo.localize(now) | |
>>> now.strftime('%Y-%m-%dT%H:%M:%S%z') | |
'2010-07-10T03:31:34+0900' | |
>>> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- a/atom.py | |
+++ b/atom.py | |
@@ -1,5 +1,5 @@ | |
def format_iso8601(obj): | |
"""Format a datetime object for iso8601""" | |
- return obj.strftime('%Y-%m-%dT%H:%M:%SZ') | |
+ return obj.strftime('%Y-%m-%dT%H:%M:%S%z') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment