paul@41 | 1 | #!/usr/bin/env python |
paul@41 | 2 | |
paul@41 | 3 | from vRecurrence import * |
paul@41 | 4 | |
paul@41 | 5 | def show(l): |
paul@41 | 6 | for x in l: |
paul@41 | 7 | print x |
paul@41 | 8 | print |
paul@41 | 9 | |
paul@41 | 10 | qualifiers = [ |
paul@41 | 11 | ("YEARLY", {"interval" : 1}) |
paul@41 | 12 | ] |
paul@41 | 13 | |
paul@41 | 14 | l = order_qualifiers(qualifiers) |
paul@41 | 15 | show(l) |
paul@41 | 16 | dt = (1997, 11, 2) |
paul@41 | 17 | l = get_datetime_structure(dt) |
paul@41 | 18 | show(l) |
paul@41 | 19 | l = combine_datetime_with_qualifiers(dt, qualifiers) |
paul@41 | 20 | show(l) |
paul@41 | 21 | |
paul@41 | 22 | s = process(l) |
paul@41 | 23 | l = s.materialise((2003, 12, 24)) |
paul@41 | 24 | print len(l) == 7, len(l) |
paul@41 | 25 | print l[0] == (1997, 11, 2), l[0] |
paul@41 | 26 | print l[-1] == (2003, 11, 2), l[-1] |
paul@41 | 27 | print |
paul@41 | 28 | |
paul@41 | 29 | qualifiers = [ |
paul@41 | 30 | ("YEARLY", {"interval" : 2}), |
paul@41 | 31 | ("BYMONTH", {"values" : [1]}), |
paul@42 | 32 | ("BYDAY", {"values" : [(6, None)]}), |
paul@41 | 33 | ("BYHOUR", {"values" : [8, 9]}), |
paul@41 | 34 | ("BYMINUTE", {"values" : [30]}) |
paul@41 | 35 | ] |
paul@41 | 36 | |
paul@41 | 37 | l = order_qualifiers(qualifiers) |
paul@41 | 38 | show(l) |
paul@41 | 39 | dt = (1997, 1, 5, 8, 30, 0) |
paul@41 | 40 | l = get_datetime_structure(dt) |
paul@41 | 41 | show(l) |
paul@41 | 42 | l = combine_datetime_with_qualifiers(dt, qualifiers) |
paul@41 | 43 | show(l) |
paul@41 | 44 | |
paul@41 | 45 | s = process(l) |
paul@41 | 46 | l = s.materialise((2003, 12, 24, 0, 0, 0)) |
paul@41 | 47 | print len(l) == 34, len(l) |
paul@41 | 48 | print l[0] == (1997, 1, 4, 8, 30, 0), l[0] |
paul@41 | 49 | print l[-1] == (2003, 1, 25, 9, 30, 0), l[-1] |
paul@41 | 50 | print |
paul@41 | 51 | |
paul@41 | 52 | qualifiers = [ |
paul@41 | 53 | ("DAILY", {"interval" : 1}) |
paul@41 | 54 | ] |
paul@41 | 55 | |
paul@41 | 56 | l = order_qualifiers(qualifiers) |
paul@41 | 57 | show(l) |
paul@41 | 58 | dt = (1997, 9, 2, 9, 0, 0) |
paul@41 | 59 | l = get_datetime_structure(dt) |
paul@41 | 60 | show(l) |
paul@41 | 61 | l = combine_datetime_with_qualifiers(dt, qualifiers) |
paul@41 | 62 | show(l) |
paul@41 | 63 | |
paul@41 | 64 | s = process(l) |
paul@41 | 65 | l = s.materialise((1997, 12, 24), 10) |
paul@41 | 66 | print len(l) == 10, len(l) |
paul@41 | 67 | print l[0] == (1997, 9, 2, 9, 0, 0), l[0] |
paul@41 | 68 | print l[-1] == (1997, 9, 11, 9, 0, 0), l[-1] |
paul@41 | 69 | print |
paul@41 | 70 | |
paul@41 | 71 | qualifiers = [ |
paul@41 | 72 | ("DAILY", {"interval" : 1}) |
paul@41 | 73 | ] |
paul@41 | 74 | |
paul@41 | 75 | l = order_qualifiers(qualifiers) |
paul@41 | 76 | show(l) |
paul@41 | 77 | dt = (1997, 9, 2, 9, 0, 0) |
paul@41 | 78 | l = get_datetime_structure(dt) |
paul@41 | 79 | show(l) |
paul@41 | 80 | l = combine_datetime_with_qualifiers(dt, qualifiers) |
paul@41 | 81 | show(l) |
paul@41 | 82 | |
paul@41 | 83 | s = process(l) |
paul@41 | 84 | l = s.materialise((1997, 12, 24, 0, 0, 0)) |
paul@41 | 85 | print len(l) == 113, len(l) |
paul@41 | 86 | print l[0] == (1997, 9, 2, 9, 0, 0), l[0] |
paul@41 | 87 | print l[-1] == (1997, 12, 23, 9, 0, 0), l[-1] |
paul@41 | 88 | print |
paul@41 | 89 | |
paul@41 | 90 | qualifiers = [ |
paul@41 | 91 | ("DAILY", {"interval" : 2}) |
paul@41 | 92 | ] |
paul@41 | 93 | |
paul@41 | 94 | l = order_qualifiers(qualifiers) |
paul@41 | 95 | show(l) |
paul@41 | 96 | dt = (1997, 9, 2, 9, 0, 0) |
paul@41 | 97 | l = get_datetime_structure(dt) |
paul@41 | 98 | show(l) |
paul@41 | 99 | l = combine_datetime_with_qualifiers(dt, qualifiers) |
paul@41 | 100 | show(l) |
paul@41 | 101 | |
paul@41 | 102 | s = process(l) |
paul@41 | 103 | l = s.materialise((1997, 12, 24, 0, 0, 0)) |
paul@41 | 104 | print len(l) == 57, len(l) |
paul@41 | 105 | print l[0] == (1997, 9, 2, 9, 0, 0), l[0] |
paul@41 | 106 | print l[-1] == (1997, 12, 23, 9, 0, 0), l[-1] |
paul@41 | 107 | print |
paul@41 | 108 | |
paul@41 | 109 | qualifiers = [ |
paul@41 | 110 | ("WEEKLY", {"interval" : 1}) |
paul@41 | 111 | ] |
paul@41 | 112 | |
paul@41 | 113 | l = order_qualifiers(qualifiers) |
paul@41 | 114 | show(l) |
paul@41 | 115 | dt = (1997, 9, 2, 9, 0, 0) |
paul@41 | 116 | l = get_datetime_structure(dt) |
paul@41 | 117 | show(l) |
paul@41 | 118 | l = combine_datetime_with_qualifiers(dt, qualifiers) |
paul@41 | 119 | show(l) |
paul@41 | 120 | |
paul@41 | 121 | s = process(l) |
paul@41 | 122 | l = s.materialise((1997, 12, 24, 0, 0, 0)) |
paul@41 | 123 | print len(l) == 17, len(l) |
paul@41 | 124 | print l[0] == (1997, 9, 2, 9, 0, 0), l[0] |
paul@41 | 125 | print l[-1] == (1997, 12, 23, 9, 0, 0), l[-1] |
paul@41 | 126 | print |
paul@41 | 127 | |
paul@41 | 128 | qualifiers = [ |
paul@41 | 129 | ("DAILY", {"interval" : 10}) |
paul@41 | 130 | ] |
paul@41 | 131 | |
paul@41 | 132 | l = order_qualifiers(qualifiers) |
paul@41 | 133 | show(l) |
paul@41 | 134 | dt = (1997, 9, 2, 9, 0, 0) |
paul@41 | 135 | l = get_datetime_structure(dt) |
paul@41 | 136 | show(l) |
paul@41 | 137 | l = combine_datetime_with_qualifiers(dt, qualifiers) |
paul@41 | 138 | show(l) |
paul@41 | 139 | |
paul@41 | 140 | s = process(l) |
paul@41 | 141 | l = s.materialise((1997, 12, 24, 0, 0, 0), 5) |
paul@41 | 142 | print len(l) == 5, len(l) |
paul@41 | 143 | print l[0] == (1997, 9, 2, 9, 0, 0), l[0] |
paul@41 | 144 | print l[-1] == (1997, 10, 12, 9, 0, 0), l[-1] |
paul@41 | 145 | print |
paul@41 | 146 | |
paul@41 | 147 | qualifiers = [ |
paul@41 | 148 | ("YEARLY", {"interval" : 1}), |
paul@41 | 149 | ("BYMONTH", {"values" : [1]}), |
paul@42 | 150 | ("BYDAY", {"values" : [(1, None), (2, None), (3, None), (4, None), (5, None), (6, None), (7, None)]}) |
paul@41 | 151 | ] |
paul@41 | 152 | |
paul@41 | 153 | l = order_qualifiers(qualifiers) |
paul@41 | 154 | show(l) |
paul@41 | 155 | dt = (1998, 1, 1, 9, 0, 0) |
paul@41 | 156 | l = get_datetime_structure(dt) |
paul@41 | 157 | show(l) |
paul@41 | 158 | l = combine_datetime_with_qualifiers(dt, qualifiers) |
paul@41 | 159 | show(l) |
paul@41 | 160 | |
paul@41 | 161 | s = process(l) |
paul@41 | 162 | l = s.materialise((2000, 1, 31, 14, 0, 0)) |
paul@41 | 163 | print len(l) == 93, len(l) |
paul@41 | 164 | print l[0] == (1998, 1, 1, 9, 0, 0), l[0] |
paul@41 | 165 | print l[-1] == (2000, 1, 31, 9, 0, 0), l[-1] |
paul@41 | 166 | print |
paul@41 | 167 | |
paul@41 | 168 | qualifiers = [ |
paul@41 | 169 | ("DAILY", {"interval" : 1}), |
paul@41 | 170 | ("BYMONTH", {"values" : [1]}) |
paul@41 | 171 | ] |
paul@41 | 172 | |
paul@41 | 173 | l = order_qualifiers(qualifiers) |
paul@41 | 174 | show(l) |
paul@41 | 175 | dt = (1998, 1, 1, 9, 0, 0) |
paul@41 | 176 | l = get_datetime_structure(dt) |
paul@41 | 177 | show(l) |
paul@41 | 178 | l = combine_datetime_with_qualifiers(dt, qualifiers) |
paul@41 | 179 | show(l) |
paul@41 | 180 | |
paul@41 | 181 | s = process(l) |
paul@41 | 182 | l = s.materialise((2000, 1, 31, 14, 0, 0)) |
paul@41 | 183 | print len(l) == 93, len(l) |
paul@41 | 184 | print l[0] == (1998, 1, 1, 9, 0, 0), l[0] |
paul@41 | 185 | print l[-1] == (2000, 1, 31, 9, 0, 0), l[-1] |
paul@41 | 186 | print |
paul@41 | 187 | |
paul@41 | 188 | qualifiers = [ |
paul@41 | 189 | ("WEEKLY", {"interval" : 1}) |
paul@41 | 190 | ] |
paul@41 | 191 | |
paul@41 | 192 | l = order_qualifiers(qualifiers) |
paul@41 | 193 | show(l) |
paul@41 | 194 | dt = (1997, 9, 2, 9, 0, 0) |
paul@41 | 195 | l = get_datetime_structure(dt) |
paul@41 | 196 | show(l) |
paul@41 | 197 | l = combine_datetime_with_qualifiers(dt, qualifiers) |
paul@41 | 198 | show(l) |
paul@41 | 199 | |
paul@41 | 200 | s = process(l) |
paul@41 | 201 | l = s.materialise((1997, 12, 24, 0, 0, 0), 10) |
paul@41 | 202 | print len(l) == 10, len(l) |
paul@41 | 203 | print l[0] == (1997, 9, 2, 9, 0, 0), l[0] |
paul@41 | 204 | print l[-1] == (1997, 11, 4, 9, 0, 0), l[-1] |
paul@41 | 205 | print |
paul@41 | 206 | |
paul@41 | 207 | qualifiers = [ |
paul@41 | 208 | ("WEEKLY", {"interval" : 1}) |
paul@41 | 209 | ] |
paul@41 | 210 | |
paul@41 | 211 | l = order_qualifiers(qualifiers) |
paul@41 | 212 | show(l) |
paul@41 | 213 | dt = (1997, 9, 2, 9, 0, 0) |
paul@41 | 214 | l = get_datetime_structure(dt) |
paul@41 | 215 | show(l) |
paul@41 | 216 | l = combine_datetime_with_qualifiers(dt, qualifiers) |
paul@41 | 217 | show(l) |
paul@41 | 218 | |
paul@41 | 219 | s = process(l) |
paul@41 | 220 | l = s.materialise((1997, 12, 24, 0, 0, 0)) |
paul@41 | 221 | print len(l) == 17, len(l) |
paul@41 | 222 | print l[0] == (1997, 9, 2, 9, 0, 0), l[0] |
paul@41 | 223 | print l[-1] == (1997, 12, 23, 9, 0, 0), l[-1] |
paul@41 | 224 | print |
paul@41 | 225 | |
paul@41 | 226 | qualifiers = [ |
paul@41 | 227 | ("WEEKLY", {"interval" : 2}) |
paul@41 | 228 | ] |
paul@41 | 229 | |
paul@41 | 230 | l = order_qualifiers(qualifiers) |
paul@41 | 231 | show(l) |
paul@41 | 232 | dt = (1997, 9, 2, 9, 0, 0) |
paul@41 | 233 | l = get_datetime_structure(dt) |
paul@41 | 234 | show(l) |
paul@41 | 235 | l = combine_datetime_with_qualifiers(dt, qualifiers) |
paul@41 | 236 | show(l) |
paul@41 | 237 | |
paul@41 | 238 | s = process(l) |
paul@41 | 239 | l = s.materialise((1998, 2, 20, 0, 0, 0)) |
paul@41 | 240 | print len(l) == 13, len(l) |
paul@41 | 241 | print l[0] == (1997, 9, 2, 9, 0, 0), l[0] |
paul@41 | 242 | print l[-1] == (1998, 2, 17, 9, 0, 0), l[-1] |
paul@41 | 243 | print |
paul@41 | 244 | |
paul@41 | 245 | qualifiers = [ |
paul@41 | 246 | ("WEEKLY", {"interval" : 1}), |
paul@42 | 247 | ("BYDAY", {"values" : [(2, None), (4, None)]}) |
paul@41 | 248 | ] |
paul@41 | 249 | |
paul@41 | 250 | l = order_qualifiers(qualifiers) |
paul@41 | 251 | show(l) |
paul@41 | 252 | dt = (1997, 9, 2, 9, 0, 0) |
paul@41 | 253 | l = get_datetime_structure(dt) |
paul@41 | 254 | show(l) |
paul@41 | 255 | l = combine_datetime_with_qualifiers(dt, qualifiers) |
paul@41 | 256 | show(l) |
paul@41 | 257 | |
paul@41 | 258 | s = process(l) |
paul@41 | 259 | l = s.materialise((1997, 10, 7, 9, 0, 0)) |
paul@41 | 260 | print len(l) == 10, len(l) |
paul@41 | 261 | print l[0] == (1997, 9, 2, 9, 0, 0), l[0] |
paul@41 | 262 | print l[-1] == (1997, 10, 2, 9, 0, 0), l[-1] |
paul@41 | 263 | print |
paul@41 | 264 | |
paul@41 | 265 | qualifiers = [ |
paul@41 | 266 | ("WEEKLY", {"interval" : 1}), |
paul@42 | 267 | ("BYDAY", {"values" : [(2, None), (4, None)]}) |
paul@41 | 268 | ] |
paul@41 | 269 | |
paul@41 | 270 | l = order_qualifiers(qualifiers) |
paul@41 | 271 | show(l) |
paul@41 | 272 | dt = (1997, 9, 2, 9, 0, 0) |
paul@41 | 273 | l = get_datetime_structure(dt) |
paul@41 | 274 | show(l) |
paul@41 | 275 | l = combine_datetime_with_qualifiers(dt, qualifiers) |
paul@41 | 276 | show(l) |
paul@41 | 277 | |
paul@41 | 278 | s = process(l) |
paul@41 | 279 | l = s.materialise((1997, 12, 24, 0, 0, 0), 10) |
paul@41 | 280 | print len(l) == 10, len(l) |
paul@41 | 281 | print l[0] == (1997, 9, 2, 9, 0, 0), l[0] |
paul@41 | 282 | print l[-1] == (1997, 10, 2, 9, 0, 0), l[-1] |
paul@41 | 283 | print |
paul@41 | 284 | |
paul@41 | 285 | qualifiers = [ |
paul@41 | 286 | ("WEEKLY", {"interval" : 2}), |
paul@42 | 287 | ("BYDAY", {"values" : [(1, None), (3, None), (5, None)]}) |
paul@41 | 288 | ] |
paul@41 | 289 | |
paul@41 | 290 | l = order_qualifiers(qualifiers) |
paul@41 | 291 | show(l) |
paul@41 | 292 | dt = (1997, 9, 1, 9, 0, 0) |
paul@41 | 293 | l = get_datetime_structure(dt) |
paul@41 | 294 | show(l) |
paul@41 | 295 | l = combine_datetime_with_qualifiers(dt, qualifiers) |
paul@41 | 296 | show(l) |
paul@41 | 297 | |
paul@41 | 298 | s = process(l) |
paul@41 | 299 | l = s.materialise((1997, 12, 24, 0, 0, 0)) |
paul@41 | 300 | print len(l) == 25, len(l) |
paul@41 | 301 | print l[0] == (1997, 9, 1, 9, 0, 0), l[0] |
paul@41 | 302 | print l[-1] == (1997, 12, 22, 9, 0, 0), l[-1] |
paul@41 | 303 | print |
paul@41 | 304 | |
paul@42 | 305 | qualifiers = [ |
paul@42 | 306 | ("WEEKLY", {"interval" : 2}), |
paul@42 | 307 | ("BYDAY", {"values" : [(2, None), (4, None)]}) |
paul@42 | 308 | ] |
paul@42 | 309 | |
paul@42 | 310 | l = order_qualifiers(qualifiers) |
paul@42 | 311 | show(l) |
paul@42 | 312 | dt = (1997, 9, 2, 9, 0, 0) |
paul@42 | 313 | l = get_datetime_structure(dt) |
paul@42 | 314 | show(l) |
paul@42 | 315 | l = combine_datetime_with_qualifiers(dt, qualifiers) |
paul@42 | 316 | show(l) |
paul@42 | 317 | |
paul@42 | 318 | s = process(l) |
paul@42 | 319 | l = s.materialise((1997, 12, 24, 0, 0, 0), 8) |
paul@42 | 320 | print len(l) == 8, len(l) |
paul@42 | 321 | print l[0] == (1997, 9, 2, 9, 0, 0), l[0] |
paul@42 | 322 | print l[-1] == (1997, 10, 16, 9, 0, 0), l[-1] |
paul@42 | 323 | print |
paul@42 | 324 | |
paul@42 | 325 | qualifiers = [ |
paul@42 | 326 | ("MONTHLY", {"interval" : 1}), |
paul@42 | 327 | ("BYDAY", {"values" : [(5, 0)]}) |
paul@42 | 328 | ] |
paul@42 | 329 | |
paul@42 | 330 | l = order_qualifiers(qualifiers) |
paul@42 | 331 | show(l) |
paul@42 | 332 | dt = (1997, 9, 5, 9, 0, 0) |
paul@42 | 333 | l = get_datetime_structure(dt) |
paul@42 | 334 | show(l) |
paul@42 | 335 | l = combine_datetime_with_qualifiers(dt, qualifiers) |
paul@42 | 336 | show(l) |
paul@42 | 337 | |
paul@42 | 338 | s = process(l) |
paul@42 | 339 | l = s.materialise((1998, 12, 24, 0, 0, 0), 10) |
paul@42 | 340 | print len(l) == 10, len(l) |
paul@42 | 341 | print l[0] == (1997, 9, 5, 9, 0, 0), l[0] |
paul@42 | 342 | print l[-1] == (1998, 6, 5, 9, 0, 0), l[-1] |
paul@42 | 343 | print |
paul@42 | 344 | |
paul@42 | 345 | qualifiers = [ |
paul@42 | 346 | ("MONTHLY", {"interval" : 1}), |
paul@42 | 347 | ("BYDAY", {"values" : [(5, 0)]}) |
paul@42 | 348 | ] |
paul@42 | 349 | |
paul@42 | 350 | l = order_qualifiers(qualifiers) |
paul@42 | 351 | show(l) |
paul@42 | 352 | dt = (1997, 9, 5, 9, 0, 0) |
paul@42 | 353 | l = get_datetime_structure(dt) |
paul@42 | 354 | show(l) |
paul@42 | 355 | l = combine_datetime_with_qualifiers(dt, qualifiers) |
paul@42 | 356 | show(l) |
paul@42 | 357 | |
paul@42 | 358 | s = process(l) |
paul@42 | 359 | l = s.materialise((1997, 12, 24, 0, 0, 0)) |
paul@42 | 360 | print len(l) == 4, len(l) |
paul@42 | 361 | print l[0] == (1997, 9, 5, 9, 0, 0), l[0] |
paul@42 | 362 | print l[-1] == (1997, 12, 5, 9, 0, 0), l[-1] |
paul@42 | 363 | print |
paul@42 | 364 | |
paul@42 | 365 | qualifiers = [ |
paul@42 | 366 | ("MONTHLY", {"interval" : 2}), |
paul@42 | 367 | ("BYDAY", {"values" : [(7, 0), (7, -1)]}) |
paul@42 | 368 | ] |
paul@42 | 369 | |
paul@42 | 370 | l = order_qualifiers(qualifiers) |
paul@42 | 371 | show(l) |
paul@42 | 372 | dt = (1997, 9, 7, 9, 0, 0) |
paul@42 | 373 | l = get_datetime_structure(dt) |
paul@42 | 374 | show(l) |
paul@42 | 375 | l = combine_datetime_with_qualifiers(dt, qualifiers) |
paul@42 | 376 | show(l) |
paul@42 | 377 | |
paul@42 | 378 | s = process(l) |
paul@42 | 379 | l = s.materialise((1998, 12, 24, 0, 0, 0), 10) |
paul@42 | 380 | print len(l) == 10, len(l) |
paul@42 | 381 | print l[0] == (1997, 9, 7, 9, 0, 0), l[0] |
paul@42 | 382 | print l[-1] == (1998, 5, 31, 9, 0, 0), l[-1] |
paul@42 | 383 | print |
paul@42 | 384 | |
paul@42 | 385 | qualifiers = [ |
paul@42 | 386 | ("MONTHLY", {"interval" : 1}), |
paul@42 | 387 | ("BYDAY", {"values" : [(1, -2)]}) |
paul@42 | 388 | ] |
paul@42 | 389 | |
paul@42 | 390 | l = order_qualifiers(qualifiers) |
paul@42 | 391 | show(l) |
paul@42 | 392 | dt = (1997, 9, 22, 9, 0, 0) |
paul@42 | 393 | l = get_datetime_structure(dt) |
paul@42 | 394 | show(l) |
paul@42 | 395 | l = combine_datetime_with_qualifiers(dt, qualifiers) |
paul@42 | 396 | show(l) |
paul@42 | 397 | |
paul@42 | 398 | s = process(l) |
paul@42 | 399 | l = s.materialise((1998, 12, 24, 0, 0, 0), 6) |
paul@42 | 400 | print len(l) == 6, len(l) |
paul@42 | 401 | print l[0] == (1997, 9, 22, 9, 0, 0), l[0] |
paul@42 | 402 | print l[-1] == (1998, 2, 16, 9, 0, 0), l[-1] |
paul@42 | 403 | print |
paul@42 | 404 | |
paul@41 | 405 | # vim: tabstop=4 expandtab shiftwidth=4 |