1.1 --- a/imiptools/data.py Fri Jan 19 19:26:36 2018 +0100
1.2 +++ b/imiptools/data.py Sat Jan 20 17:41:23 2018 +0100
1.3 @@ -181,6 +181,34 @@
1.4
1.5 return map(self.get_recurrence_start_point, recurrenceids)
1.6
1.7 + def make_recurrence(self, period, with_id=True):
1.8 +
1.9 + "Return a new recurrence based on the given 'period' in this object."
1.10 +
1.11 + obj = self.copy()
1.12 +
1.13 + # Remove all temporal information.
1.14 +
1.15 + obj.remove_all(["EXDATE", "RRULE", "RDATE", "DTSTART", "DTEND",
1.16 + "DURATION"])
1.17 +
1.18 + # Set the main period.
1.19 +
1.20 + obj.set_datetime("DTSTART", period.get_start())
1.21 + obj.set_datetime("DTEND", period.get_end())
1.22 +
1.23 + # Set a recurrence identifier if requested.
1.24 +
1.25 + if with_id:
1.26 +
1.27 + # Acquire the original recurrence identifier associated with this
1.28 + # period. This may differ where the start of the period has changed.
1.29 +
1.30 + dt, attr = period.get_recurrenceid_item()
1.31 + obj["RECURRENCE-ID"] = [(format_datetime(dt), attr)]
1.32 +
1.33 + return obj
1.34 +
1.35 # Structure access.
1.36
1.37 def add(self, obj):