1.1 --- a/docs/preferences.txt Sat Sep 19 22:09:25 2015 +0200
1.2 +++ b/docs/preferences.txt Sat Sep 19 23:01:37 2015 +0200
1.3 @@ -70,15 +70,16 @@
1.4 supporting this setting when counter-proposals are made during event
1.5 scheduling.
1.6
1.7 -This setting requires a value of one of the following forms:
1.8 +This setting requires a value indicating a duration as described in the
1.9 +iCalendar format specification:
1.10
1.11 - <number of seconds>
1.12 - <number of days>d
1.13 +http://tools.ietf.org/html/rfc5545#section-3.3.6
1.14
1.15 For example:
1.16
1.17 - 600 extend scheduling offers for 10 minutes
1.18 - 1d extend offers for 1 day
1.19 + PT10M extend scheduling offers for 10 minutes
1.20 + PT600S extend scheduling offers for 600 seconds (10 minutes)
1.21 + PT1D extend offers for 1 day
1.22
1.23 freebusy_publishing
1.24 -------------------
2.1 --- a/imiptools/client.py Sat Sep 19 22:09:25 2015 +0200
2.2 +++ b/imiptools/client.py Sat Sep 19 23:01:37 2015 +0200
2.3 @@ -25,7 +25,7 @@
2.4 is_new_object, make_freebusy, to_part, \
2.5 uri_dict, uri_items, uri_values
2.6 from imiptools.dates import check_permitted_values, format_datetime, get_default_timezone, \
2.7 - get_timestamp, to_timezone
2.8 + get_duration, get_time, get_timestamp
2.9 from imiptools.period import can_schedule, remove_period, \
2.10 remove_additional_periods, remove_affected_period, \
2.11 update_freebusy
2.12 @@ -139,28 +139,14 @@
2.13
2.14 def get_offer_period(self):
2.15
2.16 - """
2.17 - Decode a specification of one of the following forms...
2.18 -
2.19 - <number of seconds>
2.20 - <number of days>d
2.21 - """
2.22 + "Decode a specification in the iCalendar duration format."
2.23
2.24 prefs = self.get_preferences()
2.25 duration = prefs and prefs.get("freebusy_offers", config.FREEBUSY_OFFER_DEFAULT)
2.26 - if duration:
2.27 - try:
2.28 - if duration.endswith("d"):
2.29 - return timedelta(days=int(duration[:-1]))
2.30 - else:
2.31 - return timedelta(seconds=int(duration))
2.32
2.33 - # NOTE: Should probably report an error somehow.
2.34 + # NOTE: Should probably report an error somehow if None.
2.35
2.36 - except ValueError:
2.37 - return None
2.38 - else:
2.39 - return None
2.40 + return duration and get_duration(duration) or None
2.41
2.42 def get_organiser_replacement(self):
2.43 prefs = self.get_preferences()
2.44 @@ -385,7 +371,7 @@
2.45 "Update the DTSTAMP in the current object."
2.46
2.47 dtstamp = self.obj.get_utc_datetime("DTSTAMP")
2.48 - utcnow = to_timezone(datetime.utcnow(), "UTC")
2.49 + utcnow = get_time()
2.50 self.dtstamp = format_datetime(dtstamp and dtstamp > utcnow and dtstamp or utcnow)
2.51 self.obj["DTSTAMP"] = [(self.dtstamp, {})]
2.52
2.53 @@ -683,7 +669,7 @@
2.54 if offer:
2.55 offer_period = self.get_offer_period()
2.56 if offer_period:
2.57 - expires = format_datetime(to_timezone(datetime.utcnow(), "UTC") + offer_period)
2.58 + expires = get_timestamp(offer_period)
2.59 else:
2.60 return
2.61 else:
3.1 --- a/imiptools/dates.py Sat Sep 19 22:09:25 2015 +0200
3.2 +++ b/imiptools/dates.py Sat Sep 19 23:01:37 2015 +0200
3.3 @@ -132,7 +132,10 @@
3.4
3.5 def get_duration(value):
3.6
3.7 - "Return a duration for the given 'value'."
3.8 + """
3.9 + Return a duration for the given 'value' as a timedelta object.
3.10 + Where no valid duration is specified, None is returned.
3.11 + """
3.12
3.13 if not value:
3.14 return None
3.15 @@ -433,11 +436,19 @@
3.16 else:
3.17 return None, None
3.18
3.19 -def get_timestamp():
3.20 +def get_timestamp(offset=None):
3.21
3.22 "Return the current time as an iCalendar-compatible string."
3.23
3.24 - return format_datetime(to_timezone(datetime.utcnow(), "UTC"))
3.25 + offset = offset or timedelta(0)
3.26 + return format_datetime(to_timezone(datetime.utcnow(), "UTC") + offset)
3.27 +
3.28 +def get_time(offset=None):
3.29 +
3.30 + "Return the current time."
3.31 +
3.32 + offset = offset or timedelta(0)
3.33 + return to_timezone(datetime.utcnow(), "UTC") + offset
3.34
3.35 def get_tzid(dtstart_attr, dtend_attr):
3.36
4.1 --- a/tests/test_resource_invitation_constraints.sh Sat Sep 19 22:09:25 2015 +0200
4.2 +++ b/tests/test_resource_invitation_constraints.sh Sat Sep 19 23:01:37 2015 +0200
4.3 @@ -35,7 +35,7 @@
4.4 echo 'Europe/Oslo' > "$PREFS/$USER/TZID"
4.5 echo 'share' > "$PREFS/$USER/freebusy_sharing"
4.6 echo '10,12,14,16,18:0,15,30,45' > "$PREFS/$USER/permitted_times"
4.7 -echo '60' > "$PREFS/$USER/freebusy_offers"
4.8 +echo 'PT60S' > "$PREFS/$USER/freebusy_offers"
4.9
4.10 "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/fb-request-sauna-all.txt" 2>> $ERROR \
4.11 | "$SHOWMAIL" \
5.1 --- a/tests/test_resource_invitation_constraints_alternative.sh Sat Sep 19 22:09:25 2015 +0200
5.2 +++ b/tests/test_resource_invitation_constraints_alternative.sh Sat Sep 19 23:01:37 2015 +0200
5.3 @@ -35,7 +35,7 @@
5.4 echo 'Europe/Oslo' > "$PREFS/$USER/TZID"
5.5 echo 'share' > "$PREFS/$USER/freebusy_sharing"
5.6 echo '10,12,14,16,18:0,15,30,45' > "$PREFS/$USER/permitted_times"
5.7 -echo '60' > "$PREFS/$USER/freebusy_offers"
5.8 +echo 'PT60S' > "$PREFS/$USER/freebusy_offers"
5.9
5.10 "$RESOURCE_SCRIPT" $ARGS < "$TEMPLATES/fb-request-sauna-all.txt" 2>> $ERROR \
5.11 | "$SHOWMAIL" \