cal = vobject.iCalendar() cal.add('prodid').value='-//'+CALENDAR_NAME+'//PYVOBJ_'+CALENDAR_SHORT_NAME+'-Cal//EN' cal.add('VTIMEZONE').tzinfo=dateutil.tz.tzlocal() #cal.add('CALSCALE').value='GREGORIAN' #cal.add('METHOD').value='PUBLISH' #cal.add('X-WR-CALNAME').value=request.build_absolute_uri() #cal.add('X-WR-TIMEZONE').value='Australia/Sydney' for event in events: ev = cal.add('vevent') ev.add('uid').value = str(event.id)+'@'+CALENDAR_SHORT_NAME dts=ev.add('dtstart') dts.value = dts.params['tzid']='E' dte=ev.add('dtend') dte.value = dte.params['tzid']='E' ev.add('summary').value = ev.add('description').value = ev.add('location').value = ev.add('status').value = alarm=ev.add('valarm') alarm.add('value').value='DURATION' alarm.add('trigger').value=datetime.timedelta(minutes=-30) text=cal.serialize() text=text.replace('tzid=E', 'TZID=EST') if False: text=text.replace('BEGIN:VTIMEZONE', """CALSCALE:GREGORIAN METHOD:PUBLISH X-WR-CALNAME:%s X-WR-TIMEZONE:Australia/Sydney BEGIN:VTIMEZONE""" % (request.build_absolute_uri())) return HttpResponse(text, mimetype='text/calendar')