# HG changeset patch # User Paul Boddie # Date 1513458064 -3600 # Node ID 68142c63482a30d18fb0d0dfa8f0fe89e80b5669 # Parent 2181c56d858117bce7b62b75369467d8145e4dea Make UNTIL impose an inclusive selection period. diff -r 2181c56d8581 -r 68142c63482a tests/internal/qualifiers.py --- a/tests/internal/qualifiers.py Sat Dec 16 21:52:11 2017 +0100 +++ b/tests/internal/qualifiers.py Sat Dec 16 22:01:04 2017 +0100 @@ -98,7 +98,7 @@ print def test5(): - qualifiers = get_qualifiers(["FREQ=DAILY", "UNTIL=19971224T000000Z"]) # UNTIL not converted + qualifiers = get_qualifiers(["FREQ=DAILY", "UNTIL=19971224T000000Z"]) dt = (1997, 9, 2, 9, 0, 0) s = select(dt, qualifiers) @@ -108,6 +108,8 @@ print l[-1] == (1997, 12, 23, 9, 0, 0), (1997, 12, 23, 9, 0, 0), l[-1] print + # See also test43. + def test6(): qualifiers = [ ("DAILY", {"interval" : 2}) @@ -637,6 +639,19 @@ print l[-1] == (2017, 12, 27), (2017, 12, 27), l[-1] print +def test43(): + qualifiers = get_qualifiers(["FREQ=DAILY", "UNTIL=19971224T090000Z"]) + dt = (1997, 9, 2, 9, 0, 0) + s = select(dt, qualifiers) + + l = s.materialise(dt, (1997, 12, 25, 0, 0, 0), True) + print len(l) == 114, 114, len(l) + print l[0] == (1997, 9, 2, 9, 0, 0), (1997, 9, 2, 9, 0, 0), l[0] + print l[-1] == (1997, 12, 24, 9, 0, 0), (1997, 12, 24, 9, 0, 0), l[-1] + print + + # See also test5. + test0 = lambda: 0 # started at 1 above tests = [ @@ -644,7 +659,7 @@ test10, test11, test12, test13, test14, test15, test16, test17, test18, test19, test20, test21, test22, test23, test24, test25, test26, test27, test28, test29, test30, test31, test32, test33, test34, test35, test36, test37, test38, test39, - test40, test41, test42 + test40, test41, test42, test43 ] if __name__ == "__main__": diff -r 2181c56d8581 -r 68142c63482a vRecurrence.py --- a/vRecurrence.py Sat Dec 16 21:52:11 2017 +0100 +++ b/vRecurrence.py Sat Dec 16 22:01:04 2017 +0100 @@ -1186,7 +1186,7 @@ "A selector ensuring that the until datetime is not passed." def materialise_items(self, context, start, end, inclusive=False): - return UntilIterator(self, context, start, end, inclusive, + return UntilIterator(self, context, start, end, True, self.get_end()) def get_end(self): @@ -1600,7 +1600,7 @@ while True: current = self.next_item(self.start, self.end) - if current >= self.until: + if current > self.until: break return current