1 #!/usr/bin/env python 2 3 from RecurrenceSupport import getRecurrence, ParseError 4 5 # Good recurrences. 6 7 s = "every single day of the second month" 8 print s 9 print "->", getRecurrence(s) 10 s = "every single day of the second month of every year" 11 print s 12 print "->", getRecurrence(s) 13 s = "every other day from the first day of every other month from the third month of every year" 14 print s 15 print "->", getRecurrence(s) 16 s = "the second day of every other month from the first month" 17 print s 18 print "->", getRecurrence(s) 19 s = "the second hour in the second day in the second month of every year" 20 print s 21 print "->", getRecurrence(s) 22 s = "every day from the second day until the 10th day of every other month until the fifth month" 23 print s 24 print "->", getRecurrence(s) 25 s = "every day from the 10th day in the second month until the 10th day in the 10th month of every third month from the first month" 26 print s 27 print "->", getRecurrence(s) 28 s = "every day of every third month from the 10th day in the second month until the 10th day in the 10th month" 29 print s 30 print "->", getRecurrence(s) 31 32 # Bad recurrences. 33 34 print 35 36 # No start or end points. 37 38 s = "every other day of every other month" 39 print s 40 try: 41 print "->", getRecurrence(s) 42 except ParseError, exc: 43 print exc 44 45 s = "every other day of every other month from the third month of every year" 46 print s 47 try: 48 print "->", getRecurrence(s) 49 except ParseError, exc: 50 print exc 51 52 s = "the second day of every other month" 53 print s 54 try: 55 print "->", getRecurrence(s) 56 except ParseError, exc: 57 print exc 58 59 s = "every day from the second day until the 10th day of every other month" 60 print s 61 try: 62 print "->", getRecurrence(s) 63 except ParseError, exc: 64 print exc 65 66 s = "every day from the 10th day in the second month until the 10th day in the 10th month of every third month" 67 print s 68 try: 69 print "->", getRecurrence(s) 70 except ParseError, exc: 71 print exc 72 73 # Syntax error: need to use "of" instead of "in". 74 75 s = "every single day in the second month" 76 print s 77 try: 78 print "->", getRecurrence(s) 79 except ParseError, exc: 80 print exc 81 82 # Out of order: days do not contain months. 83 84 s = "every other month from the first month of every other day from the first day" 85 print s 86 try: 87 print "->", getRecurrence(s) 88 except ParseError, exc: 89 print exc 90 91 # vim: tabstop=4 expandtab shiftwidth=4