Permalink
Browse files

restored an inscrutible but necessary pytz tzinfo quirk to the start/…

…end time calculations in ical export
  • Loading branch information...
1 parent 841fefb commit 77872234233120fe12fad050ccbfbc9481396fa2 Stig Hackvan committed with stig hackvan Jan 21, 2011
Showing with 3 additions and 4 deletions.
  1. +3 −4 main.py
View
@@ -16,6 +16,7 @@
import PyRSS2Gen
import re
+import pytz
webapp.template.register_template_library('templatefilters')
@@ -69,7 +70,6 @@ def post(self):
for event in events:
notify_owner_expiring(event)
-
class ExportHandler(webapp.RequestHandler):
def get(self, format):
events = Event.all().filter('status IN', ['approved', 'canceled']).order('start_time')
@@ -80,7 +80,6 @@ def get(self, format):
self.response.out.write(simplejson.dumps(events))
elif format == 'ics':
cal = Calendar()
- #tzinfo=pytz.timezone('US/Pacific') # FIXME -- ummm, what's up with doing all this start/end_time.replace(tzinfo) nonsense?
for event in events:
iev = CalendarEvent()
iev.add('summary', event.name if event.status == 'approved' else event.name + ' (%s)' % event.status.upper())
@@ -103,9 +102,9 @@ def get(self, format):
iev.add('description', ev_desc)
iev.add('url', url_base + event_path(event))
if event.start_time:
- iev.add('dtstart', event.start_time)
+ iev.add('dtstart', event.start_time.replace(tzinfo=pytz.timezone('US/Pacific')))
if event.end_time:
- iev.add('dtend', event.end_time)
+ iev.add('dtend', event.end_time.replace(tzinfo=pytz.timezone('US/Pacific')))
cal.add_component(iev)
self.response.headers['content-type'] = 'text/calendar'
self.response.out.write(cal.as_string())

0 comments on commit 7787223

Please sign in to comment.