utils.py
changeset 117 f0b4097f5781
parent 115 751e3fcd11d2
child 129 67a30d680f60
--- a/utils.py	Thu Feb 12 00:31:34 2009 +0200
+++ b/utils.py	Thu Feb 12 00:57:39 2009 +0200
@@ -35,12 +35,9 @@
 
 class URLDateType (URLType) :
     """
-        Handle dates in URLs as shortened UTC datetime timestamps
+        Handle dates in URLs as naive datetime objects (with indeterminate time info)
     """
 
-    # percision = hour
-    SCALE = 60 * 60
-
     def __init__ (self, date_fmt) :
         """
             Format/parse dates using the given format
@@ -48,27 +45,19 @@
 
         self.date_fmt = date_fmt
     
-    def parse (self, sts_str) :
+    def parse (self, date_str) :
         """
-            short_timestamp_str -> datetime.datetime
+            date_str -> naive datetime.datetime
         """
         
-        # scale -> from_utc + return
-        return from_utc_timestamp(int(sts_str) * self.SCALE)
+        return datetime.datetime.strptime(date_str, self.date_fmt)
     
-    def build (self, dtz) :
+    def build (self, date) :
         """
-            datetime.datetime -> short_timestamp_str
+            datetime.date -> date_str
         """
 
-        # force it to be interpreted as UTC
-        dt_utc = dtz.replace(tzinfo=pytz.utc)
-        
-        # scale the UTC timestamp
-        sts = to_utc_timestamp(dt_utc) / self.SCALE
-        
-        # str
-        return str(sts)
+        return date.strftime(self.date_fmt)
 
 class URLTimestampType (URLType) :
     """