[snowy: 4/8] Use UTC as internal time representation



commit ab96ee956451f0b022ca22815abd4e4d8c647cff
Author: Leon Handreke <leon handreke gmail com>
Date:   Wed Feb 17 22:40:09 2010 +0100

    Use UTC as internal time representation
    
    This avoids having to deal with things like different time zones and DST.

 api/handlers.py |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
---
diff --git a/api/handlers.py b/api/handlers.py
index 183dbc3..1ce4f13 100644
--- a/api/handlers.py
+++ b/api/handlers.py
@@ -128,7 +128,7 @@ class NotesHandler(BaseHandler):
     @transaction.commit_on_success
     def update(self, request, username):
         def clean_date(date):
-            return parser.parse(date).astimezone(pytz.timezone(settings.TIME_ZONE))
+            return parser.parse(date).astimezone(pytz.utc)
 
         author = User.objects.get(username=username)
         if request.user != author:
@@ -202,8 +202,9 @@ class NoteHandler(BaseHandler):
 
 def describe_note(note):
     def local_iso(date):
-        return date.replace(tzinfo=pytz.timezone(settings.TIME_ZONE)) \
-                   .isoformat()
+        return date.replace(tzinfo=pytz.utc).isoformat()
+        #TODO: Return new format below for newer clients
+        #return date.replace(tzinfo=pytz.utc).strftime('%Y-%m-%dT%H:%M:%SZ')
 
     return {
         'guid': note.guid,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]