1.1 --- a/imiptools/data.py Tue Oct 24 18:57:49 2017 +0200
1.2 +++ b/imiptools/data.py Tue Oct 24 19:13:28 2017 +0200
1.3 @@ -1119,21 +1119,22 @@
1.4 """
1.5
1.6 self.rrule = rrule
1.7 - self.start = main_period.get_start()
1.8 - self.attr = main_period.get_start_attr()
1.9 - self.duration = main_period.get_duration()
1.10 + self.main_period = main_period
1.11 + self.tzid = tzid
1.12
1.13 parameters = rrule and get_parameters(rrule)
1.14 until = parameters.get("UNTIL")
1.15
1.16 + # Any UNTIL qualifier changes the nature of the end of the collection.
1.17 +
1.18 if until:
1.19 + attr = main_period.get_start_attr()
1.20 until_dt = to_timezone(get_datetime(until, attr), tzid)
1.21 - end = end and min(until_dt, end) or until_dt
1.22 - inclusive = True
1.23 -
1.24 - self.tzid = tzid
1.25 - self.end = end
1.26 - self.inclusive = inclusive
1.27 + self.end = end and min(until_dt, end) or until_dt
1.28 + self.inclusive = True
1.29 + else:
1.30 + self.end = end
1.31 + self.inclusive = inclusive
1.32
1.33 def __iter__(self):
1.34
1.35 @@ -1143,19 +1144,19 @@
1.36 done after the instances have been obtained.
1.37 """
1.38
1.39 - selector = get_rule(self.start, self.rrule)
1.40 + start = self.main_period.get_start()
1.41 + selector = get_rule(start, self.rrule)
1.42
1.43 - return RulePeriodIterator(self.duration, self.attr, self.tzid,
1.44 - selector.select(self.start, self.end,
1.45 - self.inclusive))
1.46 + return RulePeriodIterator(self.main_period, self.tzid,
1.47 + selector.select(start, self.end, self.inclusive))
1.48
1.49 class RulePeriodIterator:
1.50
1.51 "An iterator over rule periods."
1.52
1.53 - def __init__(self, duration, attr, tzid, iterator):
1.54 - self.duration = duration
1.55 - self.attr = attr
1.56 + def __init__(self, main_period, tzid, iterator):
1.57 + self.attr = main_period.get_start_attr()
1.58 + self.duration = main_period.get_duration()
1.59 self.tzid = tzid
1.60 self.iterator = iterator
1.61