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