1.1 --- a/imiptools/client.py Sat Sep 19 22:09:25 2015 +0200
1.2 +++ b/imiptools/client.py Sat Sep 19 23:01:37 2015 +0200
1.3 @@ -25,7 +25,7 @@
1.4 is_new_object, make_freebusy, to_part, \
1.5 uri_dict, uri_items, uri_values
1.6 from imiptools.dates import check_permitted_values, format_datetime, get_default_timezone, \
1.7 - get_timestamp, to_timezone
1.8 + get_duration, get_time, get_timestamp
1.9 from imiptools.period import can_schedule, remove_period, \
1.10 remove_additional_periods, remove_affected_period, \
1.11 update_freebusy
1.12 @@ -139,28 +139,14 @@
1.13
1.14 def get_offer_period(self):
1.15
1.16 - """
1.17 - Decode a specification of one of the following forms...
1.18 -
1.19 - <number of seconds>
1.20 - <number of days>d
1.21 - """
1.22 + "Decode a specification in the iCalendar duration format."
1.23
1.24 prefs = self.get_preferences()
1.25 duration = prefs and prefs.get("freebusy_offers", config.FREEBUSY_OFFER_DEFAULT)
1.26 - if duration:
1.27 - try:
1.28 - if duration.endswith("d"):
1.29 - return timedelta(days=int(duration[:-1]))
1.30 - else:
1.31 - return timedelta(seconds=int(duration))
1.32
1.33 - # NOTE: Should probably report an error somehow.
1.34 + # NOTE: Should probably report an error somehow if None.
1.35
1.36 - except ValueError:
1.37 - return None
1.38 - else:
1.39 - return None
1.40 + return duration and get_duration(duration) or None
1.41
1.42 def get_organiser_replacement(self):
1.43 prefs = self.get_preferences()
1.44 @@ -385,7 +371,7 @@
1.45 "Update the DTSTAMP in the current object."
1.46
1.47 dtstamp = self.obj.get_utc_datetime("DTSTAMP")
1.48 - utcnow = to_timezone(datetime.utcnow(), "UTC")
1.49 + utcnow = get_time()
1.50 self.dtstamp = format_datetime(dtstamp and dtstamp > utcnow and dtstamp or utcnow)
1.51 self.obj["DTSTAMP"] = [(self.dtstamp, {})]
1.52
1.53 @@ -683,7 +669,7 @@
1.54 if offer:
1.55 offer_period = self.get_offer_period()
1.56 if offer_period:
1.57 - expires = format_datetime(to_timezone(datetime.utcnow(), "UTC") + offer_period)
1.58 + expires = get_timestamp(offer_period)
1.59 else:
1.60 return
1.61 else: