1.1 --- a/imiptools/data.py Fri Oct 20 23:11:15 2017 +0200
1.2 +++ b/imiptools/data.py Fri Oct 20 23:37:08 2017 +0200
1.3 @@ -1232,11 +1232,11 @@
1.4
1.5 return RecurringPeriod(start, end, tzid, "RRULE", attr)
1.6
1.7 -def get_rule_periods(rrule, start, duration, attr, tzid, end, inclusive=False):
1.8 +def get_rule_periods(rrule, main_period, tzid, end, inclusive=False):
1.9
1.10 """
1.11 - Return periods for the given 'rrule', employing the 'start', 'duration',
1.12 - datetime 'attr' and 'tzid'.
1.13 + Return periods for the given 'rrule', employing the 'main_period' and
1.14 + 'tzid'.
1.15
1.16 The specified 'end' datetime indicates the end of the window for which
1.17 periods shall be computed.
1.18 @@ -1245,6 +1245,10 @@
1.19 will be included.
1.20 """
1.21
1.22 + start = main_period.get_start()
1.23 + attr = main_period.get_start_attr()
1.24 + duration = main_period.get_duration()
1.25 +
1.26 parameters = rrule and get_parameters(rrule)
1.27 selector = get_rule(start, rrule)
1.28
1.29 @@ -1293,9 +1297,6 @@
1.30
1.31 main_period = obj.get_main_period()
1.32
1.33 - dtstart = main_period.get_start()
1.34 - dtstart_attr = main_period.get_start_attr()
1.35 -
1.36 if not rrule:
1.37 periods = [main_period]
1.38
1.39 @@ -1312,8 +1313,8 @@
1.40 selection_period = Period(start, None)
1.41 periods = []
1.42
1.43 - for period in get_rule_periods(rrule, dtstart,
1.44 - main_period.get_duration(), dtstart_attr, tzid, end, inclusive):
1.45 + for period in get_rule_periods(rrule, main_period, tzid, end,
1.46 + inclusive):
1.47
1.48 # Use the main period where it occurs.
1.49