[icalendar-dev] How to specify a UTC offset
Thomas E. Deutsch
thomas at tuxpeople.org
Mon Apr 7 12:30:10 CEST 2008
Hello
I've created following script, to merge multiple iCals into one. But
I've a problem. I need to specify a UTC offset, 'cause Sundbird has
problems mit some of the events without it. Can someone give me a hint
how to do this?
Oh, and if you see another thing I've forgot, feel free to tell me :)
Thanks,
Thomas
import glob, sys
from icalendar import Calendar, Event, Timezone
newcal = Calendar()
newcal.add('prodid', '-//' + MY_NAME + '//' + MY_DOMAIN + '//')
newcal.add('version', '2.0')
newcal.add('x-wr-calname', CALENDARNAME)
newcal.add('X-WR-TIMEZONE', 'Europe/Zurich')
newtimezone = Timezone()
newtimezone.add('tzid', "Europe/Zurich")
newcal.add_component(newtimezone)
for s in glob.glob(CALDIR + '*.ics'):
try:
calfile = open(s,'rb')
cal = Calendar.from_string(calfile.read())
for component in cal.subcomponents:
if component.name == 'VEVENT':
newcal.add_component(component)
calfile.close()
except:
print MY_SHORTNAME + ": Error: reading file:", sys.exc_info()[1]
print s
try:
f = open(ICS_OUT, 'wb')
f.write(newcal.as_string())
f.close()
except:
print MY_SHORTNAME + ": Error: ", sys.exc_info()[1]
More information about the icalendar-dev
mailing list