--- a/handlers.py Thu Feb 12 00:31:34 2009 +0200
+++ b/handlers.py Thu Feb 12 00:57:39 2009 +0200
@@ -200,14 +200,14 @@
month = target,
)
-@preferences.handler(prefs.count)
-def channel_date (request, channel, date, count, page=1, type=None) :
+@preferences.handler(prefs.count, prefs.timezone)
+def channel_date (request, channel, date, count, timezone, page=1, type=None) :
"""
Display all log data for the given date
"""
# convert date to user's timezone
- date = date.astimezone(request.prefs['timezone'])
+ date = timezone.localize(date)
# print
# print "channel_date: date=%s" % date
--- 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) :
"""