imip-agent

Change of imiptools/dates.py

300:8d0c013ef527
imiptools/dates.py
     1.1 --- a/imiptools/dates.py	Sun Feb 08 22:52:37 2015 +0100
     1.2 +++ b/imiptools/dates.py	Mon Feb 09 14:37:21 2015 +0100
     1.3 @@ -115,14 +115,19 @@
     1.4      else:
     1.5          return None
     1.6  
     1.7 -def get_datetime_item(dt, tzid):
     1.8 +def get_datetime_item(dt, tzid=None):
     1.9  
    1.10      "Return an iCalendar-compatible string and attributes for 'dt' and 'tzid'."
    1.11  
    1.12      if not dt:
    1.13          return None, None
    1.14      value = format_datetime(dt)
    1.15 -    attr = isinstance(dt, datetime) and {"TZID" : tzid, "VALUE" : "DATE-TIME"} or {"VALUE" : "DATE"}
    1.16 +    if isinstance(dt, datetime):
    1.17 +        attr = {"VALUE" : "DATE-TIME"}
    1.18 +        if tzid:
    1.19 +            attr["TZID"] = tzid
    1.20 +    else:
    1.21 +        attr = {"VALUE" : "DATE"}
    1.22      return value, attr
    1.23  
    1.24  def get_datetime(value, attr=None):