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 11 s = "every Tuesday of 2013" 12 print s 13 print "->", getRecurrence(s) 14 15 s = "every Wednesday of every March" 16 print s 17 print "->", getRecurrence(s) 18 19 s = "every single day of every other February from 2013-02" 20 print s 21 print "->", getRecurrence(s) 22 23 s = "every other day from 2013-02-01" 24 print s 25 print "->", getRecurrence(s) 26 27 s = "every single day of the second month of 2013" 28 print s 29 print "->", getRecurrence(s) 30 31 s = "every single day of the second month in 2013" 32 print s 33 print "->", getRecurrence(s) 34 35 s = "every single day of the second month of every year" 36 print s 37 print "->", getRecurrence(s) 38 39 s = "every other day from the first day of every other month from the third month of every year" 40 print s 41 print "->", getRecurrence(s) 42 43 s = "the second day of every other month from the first month of 2012" 44 print s 45 print "->", getRecurrence(s) 46 47 s = "the second hour in the second day in the second month of every year" 48 print s 49 print "->", getRecurrence(s) 50 51 s = "every day from the second day until the 10th day of every other month until the fifth month" 52 print s 53 print "->", getRecurrence(s) 54 55 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" 56 print s 57 print "->", getRecurrence(s) 58 59 # Bad recurrences. 60 61 print 62 63 # Incomplete specification. 64 65 s = "every single day of the second month" 66 print s 67 try: 68 print "->", getRecurrence(s) 69 except ParseError, exc: 70 print exc 71 72 s = "the second day of every other month from the first month" 73 print s 74 try: 75 print "->", getRecurrence(s) 76 except ParseError, exc: 77 print exc 78 79 # Limits do not match recurrence. 80 81 s = "every single day of every other February from 2013" 82 print s 83 try: 84 print "->", getRecurrence(s) 85 except ParseError, exc: 86 print exc 87 88 s = "every single day of every other February from 2013-02-01" 89 print s 90 try: 91 print "->", getRecurrence(s) 92 except ParseError, exc: 93 print exc 94 95 s = "every day of every third month from the 10th day in the second month until the 10th day in the 10th month" 96 print s 97 try: 98 print "->", getRecurrence(s) 99 except ParseError, exc: 100 print exc 101 102 # No start or end points. 103 104 s = "every other day of every other month" 105 print s 106 try: 107 print "->", getRecurrence(s) 108 except ParseError, exc: 109 print exc 110 111 s = "every other day of every other month from the third month of every year" 112 print s 113 try: 114 print "->", getRecurrence(s) 115 except ParseError, exc: 116 print exc 117 118 s = "the second day of every other month" 119 print s 120 try: 121 print "->", getRecurrence(s) 122 except ParseError, exc: 123 print exc 124 125 s = "every day from the second day until the 10th day of every other month" 126 print s 127 try: 128 print "->", getRecurrence(s) 129 except ParseError, exc: 130 print exc 131 132 s = "every day from the 10th day in the second month until the 10th day in the 10th month of every third month" 133 print s 134 try: 135 print "->", getRecurrence(s) 136 except ParseError, exc: 137 print exc 138 139 # Syntax error: need to use "of" instead of "in". 140 141 s = "every single day in the second month" 142 print s 143 try: 144 print "->", getRecurrence(s) 145 except ParseError, exc: 146 print exc 147 148 # Out of order: days do not contain months. 149 150 s = "every other month from the first month of every other day from the first day" 151 print s 152 try: 153 print "->", getRecurrence(s) 154 except ParseError, exc: 155 print exc 156 157 # vim: tabstop=4 expandtab shiftwidth=4