From: James French Date: Mon, 4 Mar 2013 10:24:24 +0000 (+0800) Subject: Add ability to set custom timezones. X-Git-Tag: cgi-1.0~4^2~1 X-Git-Url: https://git.ucc.asn.au/?p=frenchie%2Ficalparse.git;a=commitdiff_plain;h=5d10b2313ec7bc271d7b8bc94ca8613e2de78d62;hp=4cd352c4a6906d90e171e36d3027e803009e4af6 Add ability to set custom timezones. - The rules files defaults to UTC so any scripts should change this accordingly. --- diff --git a/parserrules.py b/parserrules.py index cf60f98..f1c55c1 100644 --- a/parserrules.py +++ b/parserrules.py @@ -28,6 +28,9 @@ import vobject +ruleConfig = {} +ruleConfig["defaultTZ"] = "UTC" + def facebookOrganiser(cal): '''Adds organiser details to the body of facebook calendars.''' @@ -104,8 +107,7 @@ def exDate(cal): from datetime import datetime from pytz import timezone - default = timezone('Australia/Perth') - + default = timezone(ruleConfig["defaultTZ"]) for event in cal.vevent_list: if not event.contents.has_key(u'exdate'): continue @@ -123,12 +125,13 @@ def exDate(cal): return cal def utcise(cal): - '''Removing local timezones in favour of UTC''' + '''Removing local timezones in favour of UTC. If the remote calendar specifies a timezone + then use it, otherwise assume it's in the user-specified or default values''' from datetime import datetime from pytz import timezone - default = timezone('Australia/Perth') + default = timezone(ruleConfig["defaultTZ"]) for event in cal.vevent_list: dtstart = getattr(event, 'dtstart', None) @@ -163,7 +166,8 @@ def unwantedParams(cal): return cal def exDate(cal): - '''Changes multi-EXDATE into singles (apple can't obey even simple specs)''' + '''Changes multi-EXDATE into singles (apple can't obey even simple specs). + If the remote calendar specifies a timezone then use it, otherwise use the user specified value''' for event in cal.vevent_list: if not event.contents.has_key(u'exdate'): continue