FIX: dav_events: fixed the missing timezone info for pre_meeting fields.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import datetime
|
||||
import logging
|
||||
import pytz
|
||||
import re
|
||||
from six import string_types
|
||||
|
||||
@@ -21,7 +22,7 @@ class Iso8601Serializer(object):
|
||||
r':(?P<sec>[0-5][0-9])'
|
||||
r'([,.]\d{1,10})?'
|
||||
r')?'
|
||||
r'(?P<offset>[\-+](([01][0-9])|(2[0123]))(:[0-5][0-9])?)?$')
|
||||
r'(?P<offset>(?P<offdir>[\-+])(?P<offhours>([01][0-9])|(2[0123]))(:(?P<offmins>[0-5][0-9]))?)?$')
|
||||
|
||||
def __init__(self, instance=None, text=None):
|
||||
if instance is not None:
|
||||
@@ -66,6 +67,17 @@ class Iso8601Serializer(object):
|
||||
else:
|
||||
value = datetime.datetime(int(gd['year']), int(gd['mon']), int(gd['day']),
|
||||
hour=int(gd['hour']), minute=int(gd['min']), second=int(gd['sec']))
|
||||
if gd['offset'] is not None:
|
||||
offset = datetime.timedelta(hours=int(gd['offhours']))
|
||||
if gd['offmins'] is not None:
|
||||
offset += datetime.timedelta(minutes=int(gd['offmins']))
|
||||
if gd['offdir'] == '+':
|
||||
value -= offset
|
||||
elif gd['offdir'] == '-':
|
||||
value += offset
|
||||
else:
|
||||
raise ValueError('Offset format not recognized \'{str}\''.format(str=gd['offset']))
|
||||
value = value.replace(tzinfo=pytz.UTC)
|
||||
elif not ignore_unsupported_input:
|
||||
raise ValueError('Format not recognized \'{str}\''.format(str=haystack))
|
||||
elif not ignore_unsupported_input:
|
||||
|
||||
Reference in New Issue
Block a user