1.1 --- a/imip_manager.py Thu Feb 05 22:36:34 2015 +0100
1.2 +++ b/imip_manager.py Thu Feb 05 22:37:30 2015 +0100
1.3 @@ -184,10 +184,9 @@
1.4 if self.messenger and self.messenger.sender != get_address(attendee):
1.5 attendee_attr["SENT-BY"] = get_uri(self.messenger.sender)
1.6 self.obj["ATTENDEE"] = [(attendee, attendee_attr)]
1.7 - if update:
1.8 - sequence = self.obj.get_value("SEQUENCE") or "0"
1.9 - self.obj["SEQUENCE"] = [(str(int(sequence) + 1), {})]
1.10 +
1.11 self.update_dtstamp()
1.12 + self.set_sequence(update)
1.13
1.14 self.send_message("REPLY", get_address(attendee), for_organiser=False)
1.15
1.16 @@ -210,10 +209,9 @@
1.17
1.18 if self.messenger and self.messenger.sender != get_address(organiser):
1.19 organiser_attr["SENT-BY"] = get_uri(self.messenger.sender)
1.20 - if update:
1.21 - sequence = self.obj.get_value("SEQUENCE") or "0"
1.22 - self.obj["SEQUENCE"] = [(str(int(sequence) + 1), {})]
1.23 +
1.24 self.update_dtstamp()
1.25 + self.set_sequence(update)
1.26
1.27 self.send_message(method, get_address(self.organiser), for_organiser=True)
1.28 return True
1.29 @@ -375,6 +373,10 @@
1.30 if not slots:
1.31 return
1.32
1.33 + # Obtain the user's timezone.
1.34 +
1.35 + tzid = self.get_tzid()
1.36 +
1.37 # Coalesce the selected slots.
1.38
1.39 slots.sort()
1.40 @@ -383,14 +385,15 @@
1.41
1.42 for slot in slots:
1.43 start, end = slot.split("-")
1.44 - end = end or next_date(start)
1.45 + start = get_datetime(start, {"TZID" : tzid})
1.46 + end = end and get_datetime(end, {"TZID" : tzid}) or get_start_of_next_day(start, tzid)
1.47
1.48 if last:
1.49 last_start, last_end = last
1.50
1.51 # Merge adjacent dates and datetimes.
1.52
1.53 - if start == last_end:
1.54 + if start == last_end or get_start_of_day(last_end, tzid) == get_start_of_day(start, tzid):
1.55 last = last_start, end
1.56 continue
1.57
1.58 @@ -398,7 +401,7 @@
1.59 # Datetime periods are within single days and are therefore
1.60 # discarded.
1.61
1.62 - elif start.startswith(last_start):
1.63 + elif get_start_of_day(start, tzid) == get_start_of_day(last_start, tzid):
1.64 continue
1.65
1.66 # Add separate dates and datetimes.
1.67 @@ -411,10 +414,6 @@
1.68 if last:
1.69 coalesced.append(last)
1.70
1.71 - # Obtain the user's timezone.
1.72 -
1.73 - tzid = self.get_tzid()
1.74 -
1.75 # Invent a unique identifier.
1.76
1.77 utcnow = get_timestamp()
1.78 @@ -426,9 +425,6 @@
1.79 for i, (start, end) in enumerate(coalesced):
1.80 this_uid = "%s-%s" % (uid, i)
1.81
1.82 - start = get_datetime(start, {"TZID" : tzid})
1.83 - end = end and get_datetime(end, {"TZID" : tzid}) or get_start_of_next_day(start, tzid)
1.84 -
1.85 start_value, start_attr = get_datetime_item(start, tzid)
1.86 end_value, end_attr = get_datetime_item(end, tzid)
1.87
2.1 --- a/imiptools/content.py Thu Feb 05 22:36:34 2015 +0100
2.2 +++ b/imiptools/content.py Thu Feb 05 22:37:30 2015 +0100
2.3 @@ -397,6 +397,13 @@
2.4 utcnow = to_timezone(datetime.utcnow(), "UTC")
2.5 self.obj["DTSTAMP"] = [(format_datetime(dtstamp > utcnow and dtstamp or utcnow), {})]
2.6
2.7 + def set_sequence(self, increment=False):
2.8 +
2.9 + "Update the SEQUENCE in the current object."
2.10 +
2.11 + sequence = self.obj.get_value("SEQUENCE") or "0"
2.12 + self.obj["SEQUENCE"] = [(str(int(sequence) + (increment and 1 or 0)), {})]
2.13 +
2.14 # Handler registry.
2.15
2.16 methods = {