1.1 --- a/imiptools/dates.py Fri Mar 06 21:41:56 2015 +0100
1.2 +++ b/imiptools/dates.py Fri Mar 06 23:32:08 2015 +0100
1.3 @@ -26,14 +26,16 @@
1.4
1.5 # iCalendar date and datetime parsing (from DateSupport in MoinSupport).
1.6
1.7 -date_icalendar_regexp_str = ur'(?P<year>[0-9]{4})(?P<month>[0-9]{2})(?P<day>[0-9]{2})'
1.8 -datetime_icalendar_regexp_str = date_icalendar_regexp_str + \
1.9 +_date_icalendar_regexp_str = ur'(?P<year>[0-9]{4})(?P<month>[0-9]{2})(?P<day>[0-9]{2})'
1.10 +date_icalendar_regexp_str = _date_icalendar_regexp_str + '$'
1.11 +
1.12 +datetime_icalendar_regexp_str = _date_icalendar_regexp_str + \
1.13 ur'(?:' \
1.14 ur'T(?P<hour>[0-2][0-9])(?P<minute>[0-5][0-9])(?P<second>[0-6][0-9])' \
1.15 ur'(?P<utc>Z)?' \
1.16 - ur')?'
1.17 + ur')?$'
1.18
1.19 -duration_time_icalendar_regexp_str = \
1.20 +_duration_time_icalendar_regexp_str = \
1.21 ur'T' \
1.22 ur'(?:' \
1.23 ur'([0-9]+H)(?:([0-9]+M)([0-9]+S)?)?' \
1.24 @@ -50,7 +52,7 @@
1.25 ur'(?:%s)' \
1.26 ur'|' \
1.27 ur'([0-9]+D)(?:%s)?' \
1.28 - ur')' % (duration_time_icalendar_regexp_str, duration_time_icalendar_regexp_str)
1.29 + ur')$' % (_duration_time_icalendar_regexp_str, _duration_time_icalendar_regexp_str)
1.30
1.31 match_date_icalendar = re.compile(date_icalendar_regexp_str, re.UNICODE).match
1.32 match_datetime_icalendar = re.compile(datetime_icalendar_regexp_str, re.UNICODE).match
1.33 @@ -203,11 +205,17 @@
1.34 if len(t) != 2:
1.35 return None
1.36
1.37 - start = get_datetime(t[0])
1.38 + dtattr = {}
1.39 + if attr:
1.40 + dtattr.update(attr)
1.41 + if dtattr.has_key("VALUE"):
1.42 + del dtattr["VALUE"]
1.43 +
1.44 + start = get_datetime(t[0], dtattr)
1.45 if t[1].startswith("P"):
1.46 end = start + get_duration(t[1])
1.47 else:
1.48 - end = get_datetime(t[1])
1.49 + end = get_datetime(t[1], dtattr)
1.50
1.51 return start, end
1.52