# HG changeset patch # User Paul Boddie # Date 1427217249 -3600 # Node ID 4c9b410b0e00c1dd2e71a57e24128c4b4afb2c47 # Parent c057e9aac79c391f8a32b3b813914512d0a8d235 Added missing to_datetime function. diff -r c057e9aac79c -r 4c9b410b0e00 imiptools/data.py --- a/imiptools/data.py Tue Mar 24 16:14:55 2015 +0100 +++ b/imiptools/data.py Tue Mar 24 18:14:09 2015 +0100 @@ -23,8 +23,8 @@ from datetime import datetime, timedelta from email.mime.text import MIMEText from imiptools.dates import format_datetime, get_datetime, get_duration, \ - get_freebusy_period, get_period, to_timezone, \ - to_utc_datetime + get_freebusy_period, get_period, to_datetime, \ + to_timezone, to_utc_datetime from imiptools.period import period_overlaps from pytz import timezone from vCalendar import iterwrite, parse, ParseError, to_dict, to_node diff -r c057e9aac79c -r 4c9b410b0e00 imiptools/dates.py --- a/imiptools/dates.py Tue Mar 24 16:14:55 2015 +0100 +++ b/imiptools/dates.py Tue Mar 24 18:14:09 2015 +0100 @@ -249,6 +249,18 @@ return date(dt.year, dt.month, dt.day) +def to_datetime(dt, tzid): + + """ + Return a datetime for 'dt', using the start of day for dates, and using the + 'tzid' for the conversion. + """ + + if isinstance(dt, datetime): + return dt + else: + return get_start_of_day(dt, tzid) + def get_start_of_day(dt, tzid): """