1.1 --- a/imiptools/period.py Sat Nov 25 00:11:38 2017 +0100
1.2 +++ b/imiptools/period.py Fri Dec 01 23:09:21 2017 +0100
1.3 @@ -28,7 +28,7 @@
1.4 get_start_of_day, \
1.5 get_tzid, \
1.6 to_timezone, to_utc_datetime
1.7 -from vRecurrence import get_parameters, get_rule
1.8 +from vRecurrence import get_selector
1.9
1.10 def ifnone(x, y):
1.11 if x is None: return y
1.12 @@ -422,11 +422,11 @@
1.13
1.14 "A collection of rule periods."
1.15
1.16 - def __init__(self, rrule, main_period, tzid, end, inclusive=False):
1.17 + def __init__(self, selector, until, main_period, tzid, end, inclusive=False):
1.18
1.19 """
1.20 - Initialise a period collection for the given 'rrule', employing the
1.21 - 'main_period' and 'tzid'.
1.22 + Initialise a period collection for the given 'selectors', limited by any
1.23 + 'until' datetime, employing the 'main_period' and 'tzid'.
1.24
1.25 The specified 'end' datetime indicates the end of the window for which
1.26 periods shall be computed.
1.27 @@ -435,19 +435,14 @@
1.28 will be included.
1.29 """
1.30
1.31 - self.rrule = rrule
1.32 + self.selector = selector
1.33 self.main_period = main_period
1.34 self.tzid = tzid
1.35
1.36 - parameters = rrule and get_parameters(rrule)
1.37 - until = parameters.get("UNTIL")
1.38 -
1.39 # Any UNTIL qualifier changes the nature of the end of the collection.
1.40
1.41 if until:
1.42 - attr = main_period.get_start_attr()
1.43 - until_dt = to_timezone(get_datetime(until, attr), tzid)
1.44 - self.end = end and min(until_dt, end) or until_dt
1.45 + self.end = end and min(until, end) or until
1.46 self.inclusive = True
1.47 else:
1.48 self.end = end
1.49 @@ -462,10 +457,9 @@
1.50 """
1.51
1.52 start = self.main_period.get_start()
1.53 - selector = get_rule(start, self.rrule)
1.54
1.55 return RulePeriodIterator(self.main_period, self.tzid,
1.56 - selector.select(start, self.end, self.inclusive))
1.57 + self.selector.select(start, self.end, self.inclusive))
1.58
1.59 class RulePeriodIterator:
1.60