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 day of every other month from January of 2012" 48 print s 49 print "->", getRecurrence(s) 50 51 s = "the second day of every other month from 2012-01" 52 print s 53 print "->", getRecurrence(s) 54 55 s = "the second hour in the second day in the second month of every year" 56 print s 57 print "->", getRecurrence(s) 58 59 s = "every day from the second day until the 10th day of every other month until the fifth month of every other year from 2010" 60 print s 61 print "->", getRecurrence(s) 62 63 s = "every day from the 10th day in the second month until the 10th day in the 10th month " \ 64 "of every third month from the first month of every year until 2011" 65 print s 66 print "->", getRecurrence(s) 67 68 s = "every day from the 10th day in February until the 10th day in October " \ 69 "of every third month from January of every year until 2011" 70 print s 71 print "->", getRecurrence(s) 72 73 # Bad recurrences. 74 75 print 76 77 # Incomplete specification. 78 79 s = "every single day of the second month" 80 print s 81 try: 82 print "->", getRecurrence(s) 83 except ParseError, exc: 84 print exc 85 86 s = "the second day of every other month from the first month" 87 print s 88 try: 89 print "->", getRecurrence(s) 90 except ParseError, exc: 91 print exc 92 93 s = "every day from the second day until the 10th day of every other month until the fifth month" 94 print s 95 try: 96 print "->", getRecurrence(s) 97 except ParseError, exc: 98 print exc 99 100 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" 101 print s 102 try: 103 print "->", getRecurrence(s) 104 except ParseError, exc: 105 print exc 106 107 s = "every day from the 10th day in February until the 10th day in October of every third month from January" 108 print s 109 try: 110 print "->", getRecurrence(s) 111 except ParseError, exc: 112 print exc 113 114 # Limits do not match recurrence. 115 116 s = "every single day of every other February from 2013" 117 print s 118 try: 119 print "->", getRecurrence(s) 120 except ParseError, exc: 121 print exc 122 123 s = "every single day of every other February from 2013-02-01" 124 print s 125 try: 126 print "->", getRecurrence(s) 127 except ParseError, exc: 128 print exc 129 130 s = "every day of every third month from the 10th day in the second month until the 10th day in the 10th month" 131 print s 132 try: 133 print "->", getRecurrence(s) 134 except ParseError, exc: 135 print exc 136 137 # No start or end points. 138 139 s = "every other day of every other month" 140 print s 141 try: 142 print "->", getRecurrence(s) 143 except ParseError, exc: 144 print exc 145 146 s = "every other day of every other month from the third month of every year" 147 print s 148 try: 149 print "->", getRecurrence(s) 150 except ParseError, exc: 151 print exc 152 153 s = "the second day of every other month" 154 print s 155 try: 156 print "->", getRecurrence(s) 157 except ParseError, exc: 158 print exc 159 160 s = "every day from the second day until the 10th day of every other month" 161 print s 162 try: 163 print "->", getRecurrence(s) 164 except ParseError, exc: 165 print exc 166 167 s = "every day from the 10th day in the second month until the 10th day in the 10th month of every third month" 168 print s 169 try: 170 print "->", getRecurrence(s) 171 except ParseError, exc: 172 print exc 173 174 # Syntax error: need to use "of" instead of "in". 175 176 s = "every single day in the second month" 177 print s 178 try: 179 print "->", getRecurrence(s) 180 except ParseError, exc: 181 print exc 182 183 # Out of order: days do not contain months. 184 185 s = "every other month from the first month of every other day from the first day" 186 print s 187 try: 188 print "->", getRecurrence(s) 189 except ParseError, exc: 190 print exc 191 192 # vim: tabstop=4 expandtab shiftwidth=4