FIX: dav_events: fixed the missing timezone info for pre_meeting fields.
This commit is contained in:
1
TODO.txt
1
TODO.txt
@@ -1,5 +1,4 @@
|
|||||||
- FIX: validation for first_day
|
- FIX: validation for first_day
|
||||||
- FIX: no timezone on pre_meeting
|
|
||||||
|
|
||||||
- Test event list export
|
- Test event list export
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import datetime
|
import datetime
|
||||||
import logging
|
import logging
|
||||||
|
import pytz
|
||||||
import re
|
import re
|
||||||
from six import string_types
|
from six import string_types
|
||||||
|
|
||||||
@@ -21,7 +22,7 @@ class Iso8601Serializer(object):
|
|||||||
r':(?P<sec>[0-5][0-9])'
|
r':(?P<sec>[0-5][0-9])'
|
||||||
r'([,.]\d{1,10})?'
|
r'([,.]\d{1,10})?'
|
||||||
r')?'
|
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):
|
def __init__(self, instance=None, text=None):
|
||||||
if instance is not None:
|
if instance is not None:
|
||||||
@@ -66,6 +67,17 @@ class Iso8601Serializer(object):
|
|||||||
else:
|
else:
|
||||||
value = datetime.datetime(int(gd['year']), int(gd['mon']), int(gd['day']),
|
value = datetime.datetime(int(gd['year']), int(gd['mon']), int(gd['day']),
|
||||||
hour=int(gd['hour']), minute=int(gd['min']), second=int(gd['sec']))
|
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:
|
elif not ignore_unsupported_input:
|
||||||
raise ValueError('Format not recognized \'{str}\''.format(str=haystack))
|
raise ValueError('Format not recognized \'{str}\''.format(str=haystack))
|
||||||
elif not ignore_unsupported_input:
|
elif not ignore_unsupported_input:
|
||||||
|
|||||||
Reference in New Issue
Block a user