paul@152 | 1 | #!/usr/bin/env python |
paul@152 | 2 | |
paul@152 | 3 | """ |
paul@152 | 4 | Date processing functions. |
paul@152 | 5 | |
paul@152 | 6 | Copyright (C) 2014, 2015 Paul Boddie <paul@boddie.org.uk> |
paul@152 | 7 | |
paul@152 | 8 | This program is free software; you can redistribute it and/or modify it under |
paul@152 | 9 | the terms of the GNU General Public License as published by the Free Software |
paul@152 | 10 | Foundation; either version 3 of the License, or (at your option) any later |
paul@152 | 11 | version. |
paul@152 | 12 | |
paul@152 | 13 | This program is distributed in the hope that it will be useful, but WITHOUT |
paul@152 | 14 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
paul@152 | 15 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
paul@152 | 16 | details. |
paul@152 | 17 | |
paul@152 | 18 | You should have received a copy of the GNU General Public License along with |
paul@152 | 19 | this program. If not, see <http://www.gnu.org/licenses/>. |
paul@152 | 20 | """ |
paul@152 | 21 | |
paul@195 | 22 | from datetime import date, datetime, timedelta |
paul@291 | 23 | from os.path import exists |
paul@152 | 24 | from pytz import timezone, UnknownTimeZoneError |
paul@152 | 25 | import re |
paul@152 | 26 | |
paul@152 | 27 | # iCalendar date and datetime parsing (from DateSupport in MoinSupport). |
paul@152 | 28 | |
paul@388 | 29 | _date_icalendar_regexp_str = ur'(?P<year>[0-9]{4})(?P<month>[0-9]{2})(?P<day>[0-9]{2})' |
paul@388 | 30 | date_icalendar_regexp_str = _date_icalendar_regexp_str + '$' |
paul@388 | 31 | |
paul@388 | 32 | datetime_icalendar_regexp_str = _date_icalendar_regexp_str + \ |
paul@152 | 33 | ur'(?:' \ |
paul@152 | 34 | ur'T(?P<hour>[0-2][0-9])(?P<minute>[0-5][0-9])(?P<second>[0-6][0-9])' \ |
paul@152 | 35 | ur'(?P<utc>Z)?' \ |
paul@388 | 36 | ur')?$' |
paul@152 | 37 | |
paul@388 | 38 | _duration_time_icalendar_regexp_str = \ |
paul@387 | 39 | ur'T' \ |
paul@387 | 40 | ur'(?:' \ |
paul@387 | 41 | ur'([0-9]+H)(?:([0-9]+M)([0-9]+S)?)?' \ |
paul@387 | 42 | ur'|' \ |
paul@387 | 43 | ur'([0-9]+M)([0-9]+S)?' \ |
paul@387 | 44 | ur'|' \ |
paul@387 | 45 | ur'([0-9]+S)' \ |
paul@387 | 46 | ur')' |
paul@387 | 47 | |
paul@387 | 48 | duration_icalendar_regexp_str = ur'P' \ |
paul@387 | 49 | ur'(?:' \ |
paul@387 | 50 | ur'([0-9]+W)' \ |
paul@387 | 51 | ur'|' \ |
paul@387 | 52 | ur'(?:%s)' \ |
paul@387 | 53 | ur'|' \ |
paul@387 | 54 | ur'([0-9]+D)(?:%s)?' \ |
paul@388 | 55 | ur')$' % (_duration_time_icalendar_regexp_str, _duration_time_icalendar_regexp_str) |
paul@387 | 56 | |
paul@152 | 57 | match_date_icalendar = re.compile(date_icalendar_regexp_str, re.UNICODE).match |
paul@152 | 58 | match_datetime_icalendar = re.compile(datetime_icalendar_regexp_str, re.UNICODE).match |
paul@387 | 59 | match_duration_icalendar = re.compile(duration_icalendar_regexp_str, re.UNICODE).match |
paul@152 | 60 | |
paul@551 | 61 | # Datetime formatting. |
paul@152 | 62 | |
paul@152 | 63 | def format_datetime(dt): |
paul@247 | 64 | |
paul@247 | 65 | "Format 'dt' as an iCalendar-compatible string." |
paul@247 | 66 | |
paul@152 | 67 | if not dt: |
paul@152 | 68 | return None |
paul@152 | 69 | elif isinstance(dt, datetime): |
paul@152 | 70 | if dt.tzname() == "UTC": |
paul@152 | 71 | return dt.strftime("%Y%m%dT%H%M%SZ") |
paul@152 | 72 | else: |
paul@152 | 73 | return dt.strftime("%Y%m%dT%H%M%S") |
paul@152 | 74 | else: |
paul@152 | 75 | return dt.strftime("%Y%m%d") |
paul@152 | 76 | |
paul@285 | 77 | def format_time(dt): |
paul@285 | 78 | |
paul@285 | 79 | "Format the time portion of 'dt' as an iCalendar-compatible string." |
paul@285 | 80 | |
paul@285 | 81 | if not dt: |
paul@285 | 82 | return None |
paul@285 | 83 | elif isinstance(dt, datetime): |
paul@285 | 84 | if dt.tzname() == "UTC": |
paul@285 | 85 | return dt.strftime("%H%M%SZ") |
paul@285 | 86 | else: |
paul@285 | 87 | return dt.strftime("%H%M%S") |
paul@285 | 88 | else: |
paul@285 | 89 | return None |
paul@285 | 90 | |
paul@551 | 91 | # Parsing of datetime and related information. |
paul@239 | 92 | |
paul@152 | 93 | def get_datetime(value, attr=None): |
paul@152 | 94 | |
paul@152 | 95 | """ |
paul@152 | 96 | Return a datetime object from the given 'value' in iCalendar format, using |
paul@152 | 97 | the 'attr' mapping (if specified) to control the conversion. |
paul@152 | 98 | """ |
paul@152 | 99 | |
paul@295 | 100 | if not value: |
paul@295 | 101 | return None |
paul@295 | 102 | |
paul@285 | 103 | if len(value) > 9 and (not attr or attr.get("VALUE") in (None, "DATE-TIME")): |
paul@152 | 104 | m = match_datetime_icalendar(value) |
paul@152 | 105 | if m: |
paul@232 | 106 | year, month, day, hour, minute, second = map(m.group, [ |
paul@232 | 107 | "year", "month", "day", "hour", "minute", "second" |
paul@232 | 108 | ]) |
paul@152 | 109 | |
paul@232 | 110 | if hour and minute and second: |
paul@232 | 111 | dt = datetime( |
paul@232 | 112 | int(year), int(month), int(day), int(hour), int(minute), int(second) |
paul@232 | 113 | ) |
paul@152 | 114 | |
paul@232 | 115 | # Impose the indicated timezone. |
paul@232 | 116 | # NOTE: This needs an ambiguity policy for DST changes. |
paul@232 | 117 | |
paul@232 | 118 | return to_timezone(dt, m.group("utc") and "UTC" or attr and attr.get("TZID") or None) |
paul@152 | 119 | |
paul@285 | 120 | return None |
paul@285 | 121 | |
paul@239 | 122 | # Permit dates even if the VALUE is not set to DATE. |
paul@239 | 123 | |
paul@239 | 124 | if not attr or attr.get("VALUE") in (None, "DATE"): |
paul@152 | 125 | m = match_date_icalendar(value) |
paul@152 | 126 | if m: |
paul@232 | 127 | year, month, day = map(m.group, ["year", "month", "day"]) |
paul@232 | 128 | return date(int(year), int(month), int(day)) |
paul@232 | 129 | |
paul@152 | 130 | return None |
paul@152 | 131 | |
paul@551 | 132 | def get_duration(value): |
paul@551 | 133 | |
paul@551 | 134 | "Return a duration for the given 'value'." |
paul@551 | 135 | |
paul@551 | 136 | if not value: |
paul@551 | 137 | return None |
paul@551 | 138 | |
paul@551 | 139 | m = match_duration_icalendar(value) |
paul@551 | 140 | if m: |
paul@551 | 141 | weeks, days, hours, minutes, seconds = 0, 0, 0, 0, 0 |
paul@551 | 142 | for s in m.groups(): |
paul@551 | 143 | if not s: continue |
paul@551 | 144 | if s[-1] == "W": weeks += int(s[:-1]) |
paul@551 | 145 | elif s[-1] == "D": days += int(s[:-1]) |
paul@551 | 146 | elif s[-1] == "H": hours += int(s[:-1]) |
paul@551 | 147 | elif s[-1] == "M": minutes += int(s[:-1]) |
paul@551 | 148 | elif s[-1] == "S": seconds += int(s[:-1]) |
paul@551 | 149 | return timedelta( |
paul@551 | 150 | int(weeks) * 7 + int(days), |
paul@551 | 151 | (int(hours) * 60 + int(minutes)) * 60 + int(seconds) |
paul@551 | 152 | ) |
paul@551 | 153 | else: |
paul@551 | 154 | return None |
paul@551 | 155 | |
paul@387 | 156 | def get_period(value, attr=None): |
paul@387 | 157 | |
paul@387 | 158 | """ |
paul@387 | 159 | Return a tuple of the form (start, end) for the given 'value' in iCalendar |
paul@387 | 160 | format, using the 'attr' mapping (if specified) to control the conversion. |
paul@387 | 161 | """ |
paul@387 | 162 | |
paul@630 | 163 | if not value or attr and attr.get("VALUE") and attr.get("VALUE") != "PERIOD": |
paul@387 | 164 | return None |
paul@387 | 165 | |
paul@387 | 166 | t = value.split("/") |
paul@387 | 167 | if len(t) != 2: |
paul@387 | 168 | return None |
paul@387 | 169 | |
paul@388 | 170 | dtattr = {} |
paul@388 | 171 | if attr: |
paul@388 | 172 | dtattr.update(attr) |
paul@388 | 173 | if dtattr.has_key("VALUE"): |
paul@388 | 174 | del dtattr["VALUE"] |
paul@388 | 175 | |
paul@388 | 176 | start = get_datetime(t[0], dtattr) |
paul@387 | 177 | if t[1].startswith("P"): |
paul@387 | 178 | end = start + get_duration(t[1]) |
paul@387 | 179 | else: |
paul@388 | 180 | end = get_datetime(t[1], dtattr) |
paul@387 | 181 | |
paul@387 | 182 | return start, end |
paul@387 | 183 | |
paul@551 | 184 | # Time zone conversions and retrieval. |
paul@551 | 185 | |
paul@551 | 186 | def ends_on_same_day(dt, end, tzid): |
paul@387 | 187 | |
paul@551 | 188 | """ |
paul@551 | 189 | Return whether 'dt' ends on the same day as 'end', testing the date |
paul@551 | 190 | components of 'dt' and 'end' against each other, but also testing whether |
paul@551 | 191 | 'end' is the actual end of the day in which 'dt' is positioned. |
paul@387 | 192 | |
paul@551 | 193 | Since time zone transitions may occur within a day, 'tzid' is required to |
paul@551 | 194 | determine the end of the day in which 'dt' is positioned, using the zone |
paul@551 | 195 | appropriate at that point in time, not necessarily the zone applying to |
paul@551 | 196 | 'dt'. |
paul@551 | 197 | """ |
paul@387 | 198 | |
paul@551 | 199 | return ( |
paul@551 | 200 | to_timezone(dt, tzid).date() == to_timezone(end, tzid).date() or |
paul@551 | 201 | end == get_end_of_day(dt, tzid) |
paul@551 | 202 | ) |
paul@551 | 203 | |
paul@551 | 204 | def get_default_timezone(): |
paul@551 | 205 | |
paul@551 | 206 | "Return the system time regime." |
paul@551 | 207 | |
paul@551 | 208 | filename = "/etc/timezone" |
paul@551 | 209 | |
paul@551 | 210 | if exists(filename): |
paul@551 | 211 | f = open(filename) |
paul@551 | 212 | try: |
paul@551 | 213 | return f.read().strip() |
paul@551 | 214 | finally: |
paul@551 | 215 | f.close() |
paul@387 | 216 | else: |
paul@387 | 217 | return None |
paul@387 | 218 | |
paul@551 | 219 | def get_end_of_day(dt, tzid): |
paul@431 | 220 | |
paul@431 | 221 | """ |
paul@551 | 222 | Get the end of the day in which 'dt' is positioned, using the given 'tzid' |
paul@551 | 223 | to obtain a datetime in the appropriate time zone. Where time zone |
paul@551 | 224 | transitions occur within a day, the zone of 'dt' may not be the eventual |
paul@551 | 225 | zone of the returned object. |
paul@431 | 226 | """ |
paul@431 | 227 | |
paul@551 | 228 | return get_start_of_day(dt + timedelta(1), tzid) |
paul@431 | 229 | |
paul@244 | 230 | def get_start_of_day(dt, tzid): |
paul@245 | 231 | |
paul@245 | 232 | """ |
paul@245 | 233 | Get the start of the day in which 'dt' is positioned, using the given 'tzid' |
paul@245 | 234 | to obtain a datetime in the appropriate time zone. Where time zone |
paul@245 | 235 | transitions occur within a day, the zone of 'dt' may not be the eventual |
paul@245 | 236 | zone of the returned object. |
paul@245 | 237 | """ |
paul@245 | 238 | |
paul@244 | 239 | start = datetime(dt.year, dt.month, dt.day, 0, 0) |
paul@244 | 240 | return to_timezone(start, tzid) |
paul@152 | 241 | |
paul@244 | 242 | def get_start_of_next_day(dt, tzid): |
paul@245 | 243 | |
paul@245 | 244 | """ |
paul@245 | 245 | Get the start of the day after the day in which 'dt' is positioned. This |
paul@245 | 246 | function is intended to extend either dates or datetimes to the end of a |
paul@245 | 247 | day for the purpose of generating a missing end date or datetime for an |
paul@245 | 248 | event. |
paul@245 | 249 | |
paul@245 | 250 | If 'dt' is a date and not a datetime, a plain date object for the next day |
paul@245 | 251 | will be returned. |
paul@245 | 252 | |
paul@245 | 253 | If 'dt' is a datetime, the given 'tzid' is used to obtain a datetime in the |
paul@245 | 254 | appropriate time zone. Where time zone transitions occur within a day, the |
paul@245 | 255 | zone of 'dt' may not be the eventual zone of the returned object. |
paul@245 | 256 | """ |
paul@245 | 257 | |
paul@239 | 258 | if isinstance(dt, datetime): |
paul@239 | 259 | return get_end_of_day(dt, tzid) |
paul@239 | 260 | else: |
paul@239 | 261 | return dt + timedelta(1) |
paul@239 | 262 | |
paul@616 | 263 | def get_datetime_tzid(dt): |
paul@616 | 264 | |
paul@616 | 265 | "Return the time zone identifier from 'dt' or None if unknown." |
paul@616 | 266 | |
paul@616 | 267 | if not isinstance(dt, datetime): |
paul@616 | 268 | return None |
paul@616 | 269 | elif dt.tzname() == "UTC": |
paul@616 | 270 | return "UTC" |
paul@616 | 271 | elif dt.tzinfo and hasattr(dt.tzinfo, "zone"): |
paul@616 | 272 | return dt.tzinfo.zone |
paul@616 | 273 | else: |
paul@616 | 274 | return None |
paul@616 | 275 | |
paul@627 | 276 | def get_period_tzid(start, end): |
paul@627 | 277 | |
paul@627 | 278 | "Return the time zone identifier for 'start' and 'end' or None if unknown." |
paul@627 | 279 | |
paul@627 | 280 | if isinstance(start, datetime) or isinstance(end, datetime): |
paul@627 | 281 | return get_datetime_tzid(start) or get_datetime_tzid(end) |
paul@627 | 282 | else: |
paul@627 | 283 | return None |
paul@627 | 284 | |
paul@551 | 285 | def to_date(dt): |
paul@551 | 286 | |
paul@551 | 287 | "Return the date of 'dt'." |
paul@551 | 288 | |
paul@551 | 289 | return date(dt.year, dt.month, dt.day) |
paul@551 | 290 | |
paul@551 | 291 | def to_datetime(dt, tzid): |
paul@551 | 292 | |
paul@551 | 293 | """ |
paul@551 | 294 | Return a datetime for 'dt', using the start of day for dates, and using the |
paul@551 | 295 | 'tzid' for the conversion. |
paul@551 | 296 | """ |
paul@551 | 297 | |
paul@551 | 298 | if isinstance(dt, datetime): |
paul@551 | 299 | return dt |
paul@551 | 300 | else: |
paul@551 | 301 | return get_start_of_day(dt, tzid) |
paul@551 | 302 | |
paul@551 | 303 | def to_utc_datetime(dt, date_tzid=None): |
paul@245 | 304 | |
paul@245 | 305 | """ |
paul@551 | 306 | Return a datetime corresponding to 'dt' in the UTC time zone. If 'date_tzid' |
paul@551 | 307 | is specified, dates are converted to datetimes using the time zone |
paul@551 | 308 | information; otherwise, dates remain unconverted. |
paul@245 | 309 | """ |
paul@245 | 310 | |
paul@551 | 311 | if not dt: |
paul@551 | 312 | return None |
paul@551 | 313 | elif isinstance(dt, datetime): |
paul@551 | 314 | return to_timezone(dt, "UTC") |
paul@551 | 315 | elif date_tzid: |
paul@551 | 316 | return to_timezone(to_datetime(dt, date_tzid), "UTC") |
paul@551 | 317 | else: |
paul@551 | 318 | return dt |
paul@551 | 319 | |
paul@616 | 320 | def to_timezone(dt, tzid): |
paul@551 | 321 | |
paul@551 | 322 | """ |
paul@551 | 323 | Return a datetime corresponding to 'dt' in the time regime having the given |
paul@616 | 324 | 'tzid'. |
paul@551 | 325 | """ |
paul@195 | 326 | |
paul@551 | 327 | try: |
paul@616 | 328 | tz = tzid and timezone(tzid) or None |
paul@551 | 329 | except UnknownTimeZoneError: |
paul@551 | 330 | tz = None |
paul@551 | 331 | return to_tz(dt, tz) |
paul@551 | 332 | |
paul@551 | 333 | def to_tz(dt, tz): |
paul@247 | 334 | |
paul@551 | 335 | "Return a datetime corresponding to 'dt' employing the pytz.timezone 'tz'." |
paul@247 | 336 | |
paul@551 | 337 | if tz is not None and isinstance(dt, datetime): |
paul@551 | 338 | if not dt.tzinfo: |
paul@551 | 339 | return tz.localize(dt) |
paul@551 | 340 | else: |
paul@551 | 341 | return dt.astimezone(tz) |
paul@551 | 342 | else: |
paul@551 | 343 | return dt |
paul@222 | 344 | |
paul@551 | 345 | # iCalendar-related conversions. |
paul@551 | 346 | |
paul@551 | 347 | def end_date_from_calendar(dt): |
paul@291 | 348 | |
paul@291 | 349 | """ |
paul@551 | 350 | Change end dates to refer to the actual dates, not the iCalendar "next day" |
paul@551 | 351 | dates. |
paul@291 | 352 | """ |
paul@291 | 353 | |
paul@551 | 354 | if not isinstance(dt, datetime): |
paul@551 | 355 | return dt - timedelta(1) |
paul@551 | 356 | else: |
paul@551 | 357 | return dt |
paul@291 | 358 | |
paul@532 | 359 | def end_date_to_calendar(dt): |
paul@532 | 360 | |
paul@532 | 361 | """ |
paul@532 | 362 | Change end dates to refer to the iCalendar "next day" dates, not the actual |
paul@532 | 363 | dates. |
paul@532 | 364 | """ |
paul@532 | 365 | |
paul@532 | 366 | if not isinstance(dt, datetime): |
paul@532 | 367 | return dt + timedelta(1) |
paul@532 | 368 | else: |
paul@532 | 369 | return dt |
paul@532 | 370 | |
paul@551 | 371 | def get_datetime_attributes(dt, tzid=None): |
paul@551 | 372 | |
paul@616 | 373 | """ |
paul@616 | 374 | Return attributes for the 'dt' date or datetime object with 'tzid' |
paul@616 | 375 | indicating the time zone if not otherwise defined. |
paul@616 | 376 | """ |
paul@551 | 377 | |
paul@551 | 378 | if isinstance(dt, datetime): |
paul@551 | 379 | attr = {"VALUE" : "DATE-TIME"} |
paul@616 | 380 | tzid = get_datetime_tzid(dt) or tzid |
paul@551 | 381 | if tzid: |
paul@551 | 382 | attr["TZID"] = tzid |
paul@551 | 383 | return attr |
paul@551 | 384 | else: |
paul@551 | 385 | return {"VALUE" : "DATE"} |
paul@551 | 386 | |
paul@551 | 387 | def get_datetime_item(dt, tzid=None): |
paul@551 | 388 | |
paul@615 | 389 | """ |
paul@615 | 390 | Return an iCalendar-compatible string and attributes for 'dt' using any |
paul@616 | 391 | specified 'tzid' to assert a particular time zone if not otherwise defined. |
paul@615 | 392 | """ |
paul@551 | 393 | |
paul@551 | 394 | if not dt: |
paul@551 | 395 | return None, None |
paul@616 | 396 | if not get_datetime_tzid(dt): |
paul@616 | 397 | dt = to_timezone(dt, tzid) |
paul@551 | 398 | value = format_datetime(dt) |
paul@551 | 399 | attr = get_datetime_attributes(dt, tzid) |
paul@551 | 400 | return value, attr |
paul@551 | 401 | |
paul@627 | 402 | def get_period_attributes(start, end, tzid=None): |
paul@551 | 403 | |
paul@627 | 404 | """ |
paul@627 | 405 | Return attributes for the 'start' and 'end' datetime objects with 'tzid' |
paul@627 | 406 | indicating the time zone if not otherwise defined. |
paul@627 | 407 | """ |
paul@551 | 408 | |
paul@551 | 409 | attr = {"VALUE" : "PERIOD"} |
paul@627 | 410 | tzid = get_period_tzid(start, end) or tzid |
paul@551 | 411 | if tzid: |
paul@551 | 412 | attr["TZID"] = tzid |
paul@551 | 413 | return attr |
paul@551 | 414 | |
paul@551 | 415 | def get_period_item(start, end, tzid=None): |
paul@532 | 416 | |
paul@532 | 417 | """ |
paul@551 | 418 | Return an iCalendar-compatible string and attributes for 'start', 'end' and |
paul@551 | 419 | 'tzid'. |
paul@532 | 420 | """ |
paul@532 | 421 | |
paul@551 | 422 | if start and end: |
paul@627 | 423 | attr = get_period_attributes(start, end, tzid) |
paul@627 | 424 | start_value = format_datetime(to_timezone(start, attr.get("TZID"))) |
paul@627 | 425 | end_value = format_datetime(to_timezone(end, attr.get("TZID"))) |
paul@551 | 426 | return "%s/%s" % (start_value, end_value), attr |
paul@551 | 427 | elif start: |
paul@551 | 428 | attr = get_datetime_attributes(start, tzid) |
paul@627 | 429 | start_value = format_datetime(to_timezone(start, attr.get("TZID"))) |
paul@551 | 430 | return start_value, attr |
paul@532 | 431 | else: |
paul@551 | 432 | return None, None |
paul@551 | 433 | |
paul@551 | 434 | def get_timestamp(): |
paul@551 | 435 | |
paul@551 | 436 | "Return the current time as an iCalendar-compatible string." |
paul@551 | 437 | |
paul@551 | 438 | return format_datetime(to_timezone(datetime.utcnow(), "UTC")) |
paul@551 | 439 | |
paul@551 | 440 | def get_tzid(dtstart_attr, dtend_attr): |
paul@551 | 441 | |
paul@551 | 442 | """ |
paul@551 | 443 | Return any time regime details from the given 'dtstart_attr' and |
paul@551 | 444 | 'dtend_attr' attribute collections. |
paul@551 | 445 | """ |
paul@551 | 446 | |
paul@551 | 447 | return dtstart_attr and dtstart_attr.get("TZID") or dtend_attr and dtend_attr.get("TZID") or None |
paul@551 | 448 | |
paul@561 | 449 | def get_recurrence_start(recurrenceid): |
paul@561 | 450 | |
paul@561 | 451 | """ |
paul@561 | 452 | Return 'recurrenceid' in a form suitable for comparison with period start |
paul@627 | 453 | dates or datetimes. The 'recurrenceid' should be an identifier normalised to |
paul@627 | 454 | a UTC datetime or employing a date or floating datetime representation where |
paul@627 | 455 | no time zone information was originally provided. |
paul@561 | 456 | """ |
paul@561 | 457 | |
paul@561 | 458 | return get_datetime(recurrenceid) |
paul@561 | 459 | |
paul@561 | 460 | def get_recurrence_start_point(recurrenceid, tzid): |
paul@551 | 461 | |
paul@551 | 462 | """ |
paul@551 | 463 | Return 'recurrenceid' in a form suitable for comparison with free/busy start |
paul@551 | 464 | datetimes, using 'tzid' to convert recurrence identifiers that are dates. |
paul@627 | 465 | The 'recurrenceid' should be an identifier normalised to a UTC datetime or |
paul@627 | 466 | employing a date or floating datetime representation where no time zone |
paul@627 | 467 | information was originally provided. |
paul@551 | 468 | """ |
paul@551 | 469 | |
paul@552 | 470 | return to_utc_datetime(get_datetime(recurrenceid), tzid) |
paul@552 | 471 | |
paul@152 | 472 | # vim: tabstop=4 expandtab shiftwidth=4 |