1.1 --- a/imiptools/dates.py Tue Apr 07 18:57:35 2015 +0200
1.2 +++ b/imiptools/dates.py Tue Apr 07 22:06:39 2015 +0200
1.3 @@ -58,14 +58,20 @@
1.4 match_datetime_icalendar = re.compile(datetime_icalendar_regexp_str, re.UNICODE).match
1.5 match_duration_icalendar = re.compile(duration_icalendar_regexp_str, re.UNICODE).match
1.6
1.7 -def to_utc_datetime(dt):
1.8 +def to_utc_datetime(dt, date_tzid=None):
1.9
1.10 - "Return a datetime corresponding to 'dt' in the UTC time zone."
1.11 + """
1.12 + Return a datetime corresponding to 'dt' in the UTC time zone. If 'date_tzid'
1.13 + is specified, dates are converted to datetimes using the time zone
1.14 + information; otherwise, dates remain unconverted.
1.15 + """
1.16
1.17 if not dt:
1.18 return None
1.19 elif isinstance(dt, datetime):
1.20 return to_timezone(dt, "UTC")
1.21 + elif date_tzid:
1.22 + return to_timezone(to_datetime(dt, date_tzid), "UTC")
1.23 else:
1.24 return dt
1.25
1.26 @@ -380,21 +386,17 @@
1.27 end point defined in UTC.
1.28 """
1.29
1.30 - start = to_utc_datetime_only(start, tzid)
1.31 - end = to_utc_datetime_only(end, tzid)
1.32 + start = to_utc_datetime(start, tzid)
1.33 + end = to_utc_datetime(end, tzid)
1.34 return start, end
1.35
1.36 -def to_utc_datetime_only(dt, tzid):
1.37 +def to_recurrence_start(recurrenceid, tzid):
1.38
1.39 """
1.40 - Return the datetime 'dt' as a point in time in the UTC time zone, given the
1.41 - 'tzid' defined for the datetime. Where 'dt' is a date, the start of the
1.42 - indicated day is returned, defined in UTC.
1.43 + Return 'recurrenceid' in a form suitable for comparison with free/busy start
1.44 + datetimes, using 'tzid' to convert recurrence identifiers that are dates.
1.45 """
1.46
1.47 - if not isinstance(dt, datetime):
1.48 - return to_timezone(get_start_of_day(dt, tzid), "UTC")
1.49 - else:
1.50 - return to_timezone(dt, "UTC")
1.51 + return format_datetime(to_utc_datetime(get_datetime(recurrenceid), tzid))
1.52
1.53 # vim: tabstop=4 expandtab shiftwidth=4