[B.END] Timezones management
Achtung! compatibility with current JS is not verified
This commit is contained in:
parent
ae296f7b93
commit
4b63a58bc2
|
@ -16,4 +16,5 @@
|
||||||
|
|
||||||
# Calendar related variables
|
# Calendar related variables
|
||||||
[caldav]
|
[caldav]
|
||||||
cal_name =
|
cal_name =
|
||||||
|
local_tz =
|
16
getInfo.py
16
getInfo.py
|
@ -4,6 +4,7 @@ import datetime as dt
|
||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
import glob
|
import glob
|
||||||
|
import pytz
|
||||||
|
|
||||||
def parseOptions(arr):
|
def parseOptions(arr):
|
||||||
if len(arr) == 1:
|
if len(arr) == 1:
|
||||||
|
@ -67,11 +68,24 @@ def getEvents(baseDay, interval):
|
||||||
event_dict['NAME'] = k[1]
|
event_dict['NAME'] = k[1]
|
||||||
elif k[0] == 'DTSTART':
|
elif k[0] == 'DTSTART':
|
||||||
options = parseOptions(k[1:])
|
options = parseOptions(k[1:])
|
||||||
|
|
||||||
|
if 'TZID' in options:
|
||||||
|
event_tz = pytz.timezone(options['TZID'])
|
||||||
|
event_fmt = "%Y%m%dT%H%M%S"
|
||||||
|
# If TZID flag is not specified, datetime is UTC
|
||||||
|
else:
|
||||||
|
event_tz = pytz.timezone('UTC')
|
||||||
|
event_fmt = "%Y%m%dT%H%M%SZ"
|
||||||
|
|
||||||
|
# Check if time is set and then localize it
|
||||||
if 'VALUE' in options and options['VALUE'] == 'DATE':
|
if 'VALUE' in options and options['VALUE'] == 'DATE':
|
||||||
event_dict['DATETIME'] = dt.datetime.strptime(options['RAW'],'%Y%m%d')
|
event_dict['DATETIME'] = dt.datetime.strptime(options['RAW'],'%Y%m%d')
|
||||||
event_dict['ALLDAY'] = True
|
event_dict['ALLDAY'] = True
|
||||||
else:
|
else:
|
||||||
event_dict['DATETIME'] = dt.datetime.strptime(options['RAW'],'%Y%m%dT%H%M%S')
|
event_parsed_dt = dt.datetime.strptime(options['RAW'], event_fmt)
|
||||||
|
event_parsed_dt = event_parsed_dt.replace(tzinfo=event_tz)
|
||||||
|
local_tz = pytz.timezone(glob.cfg['caldav']['local_tz'])
|
||||||
|
event_dict['DATETIME'] = event_parsed_dt.astimezone(local_tz)
|
||||||
event_dict['ALLDAY'] = False
|
event_dict['ALLDAY'] = False
|
||||||
elif k[0] == 'LOCATION':
|
elif k[0] == 'LOCATION':
|
||||||
event_dict['LOCATION'] = k[1]
|
event_dict['LOCATION'] = k[1]
|
||||||
|
|
Loading…
Reference in New Issue