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" 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 of every third month from the first month" 64 print s 65 print "->", getRecurrence(s) 66 67 # Bad recurrences. 68 69 print 70 71 # Incomplete specification. 72 73 s = "every single day of the second month" 74 print s 75 try: 76 print "->", getRecurrence(s) 77 except ParseError, exc: 78 print exc 79 80 s = "the second day of every other month from the first month" 81 print s 82 try: 83 print "->", getRecurrence(s) 84 except ParseError, exc: 85 print exc 86 87 # Limits do not match recurrence. 88 89 s = "every single day of every other February from 2013" 90 print s 91 try: 92 print "->", getRecurrence(s) 93 except ParseError, exc: 94 print exc 95 96 s = "every single day of every other February from 2013-02-01" 97 print s 98 try: 99 print "->", getRecurrence(s) 100 except ParseError, exc: 101 print exc 102 103 s = "every day of every third month from the 10th day in the second month until the 10th day in the 10th month" 104 print s 105 try: 106 print "->", getRecurrence(s) 107 except ParseError, exc: 108 print exc 109 110 # No start or end points. 111 112 s = "every other day of every other month" 113 print s 114 try: 115 print "->", getRecurrence(s) 116 except ParseError, exc: 117 print exc 118 119 s = "every other day of every other month from the third month of every year" 120 print s 121 try: 122 print "->", getRecurrence(s) 123 except ParseError, exc: 124 print exc 125 126 s = "the second day of every other month" 127 print s 128 try: 129 print "->", getRecurrence(s) 130 except ParseError, exc: 131 print exc 132 133 s = "every day from the second day until the 10th day of every other month" 134 print s 135 try: 136 print "->", getRecurrence(s) 137 except ParseError, exc: 138 print exc 139 140 s = "every day from the 10th day in the second month until the 10th day in the 10th month of every third month" 141 print s 142 try: 143 print "->", getRecurrence(s) 144 except ParseError, exc: 145 print exc 146 147 # Syntax error: need to use "of" instead of "in". 148 149 s = "every single day in the second month" 150 print s 151 try: 152 print "->", getRecurrence(s) 153 except ParseError, exc: 154 print exc 155 156 # Out of order: days do not contain months. 157 158 s = "every other month from the first month of every other day from the first day" 159 print s 160 try: 161 print "->", getRecurrence(s) 162 except ParseError, exc: 163 print exc 164 165 # vim: tabstop=4 expandtab shiftwidth=4