1 #!/usr/bin/env python 2 3 from vRecurrence import * 4 5 def show(l): 6 for x in l: 7 print x 8 print 9 10 qualifiers = [ 11 ("YEARLY", {"interval" : 1}) 12 ] 13 14 l = order_qualifiers(qualifiers) 15 show(l) 16 dt = (1997, 11, 2) 17 l = get_datetime_structure(dt) 18 show(l) 19 l = combine_datetime_with_qualifiers(dt, qualifiers) 20 show(l) 21 22 s = get_selector(dt, qualifiers) 23 l = s.materialise(dt, (2003, 12, 24)) 24 print len(l) == 7, 7, len(l) 25 print l[0] == (1997, 11, 2), (1997, 11, 2), l[0] 26 print l[-1] == (2003, 11, 2), (2003, 11, 2), l[-1] 27 print 28 29 qualifiers = [ 30 ("YEARLY", {"interval" : 2}), 31 ("BYMONTH", {"values" : [1]}), 32 ("BYDAY", {"values" : [(6, None)]}), 33 ("BYHOUR", {"values" : [8, 9]}), 34 ("BYMINUTE", {"values" : [30]}) 35 ] 36 37 l = order_qualifiers(qualifiers) 38 show(l) 39 dt = (1997, 1, 5, 8, 30, 0) 40 l = get_datetime_structure(dt) 41 show(l) 42 l = combine_datetime_with_qualifiers(dt, qualifiers) 43 show(l) 44 45 s = get_selector(dt, qualifiers) 46 l = s.materialise(dt, (2003, 12, 24, 0, 0, 0)) 47 print len(l) == 32, 32, len(l) 48 print l[0] == (1997, 1, 11, 8, 30, 0), (1997, 1, 11, 8, 30, 0), l[0] 49 print l[-1] == (2003, 1, 25, 9, 30, 0), (2003, 1, 25, 9, 30, 0), l[-1] 50 print 51 52 qualifiers = [ 53 ("DAILY", {"interval" : 1}) 54 ] 55 56 l = order_qualifiers(qualifiers) 57 show(l) 58 dt = (1997, 9, 2, 9, 0, 0) 59 l = get_datetime_structure(dt) 60 show(l) 61 l = combine_datetime_with_qualifiers(dt, qualifiers) 62 show(l) 63 64 s = get_selector(dt, qualifiers) 65 l = s.materialise(dt, (1997, 12, 24), 10) 66 print len(l) == 10, 10, len(l) 67 print l[0] == (1997, 9, 2, 9, 0, 0), (1997, 9, 2, 9, 0, 0), l[0] 68 print l[-1] == (1997, 9, 11, 9, 0, 0), (1997, 9, 11, 9, 0, 0), l[-1] 69 print 70 71 qualifiers = [ 72 ("DAILY", {"interval" : 1}) 73 ] 74 75 l = order_qualifiers(qualifiers) 76 show(l) 77 dt = (1997, 9, 2, 9, 0, 0) 78 l = get_datetime_structure(dt) 79 show(l) 80 l = combine_datetime_with_qualifiers(dt, qualifiers) 81 show(l) 82 83 s = get_selector(dt, qualifiers) 84 l = s.materialise(dt, (1997, 12, 24, 0, 0, 0)) 85 print len(l) == 113, 113, len(l) 86 print l[0] == (1997, 9, 2, 9, 0, 0), (1997, 9, 2, 9, 0, 0), l[0] 87 print l[-1] == (1997, 12, 23, 9, 0, 0), (1997, 12, 23, 9, 0, 0), l[-1] 88 print 89 90 qualifiers = [ 91 ("DAILY", {"interval" : 2}) 92 ] 93 94 l = order_qualifiers(qualifiers) 95 show(l) 96 dt = (1997, 9, 2, 9, 0, 0) 97 l = get_datetime_structure(dt) 98 show(l) 99 l = combine_datetime_with_qualifiers(dt, qualifiers) 100 show(l) 101 102 s = get_selector(dt, qualifiers) 103 l = s.materialise(dt, (1997, 12, 24, 0, 0, 0)) 104 print len(l) == 57, 57, len(l) 105 print l[0] == (1997, 9, 2, 9, 0, 0), (1997, 9, 2, 9, 0, 0), l[0] 106 print l[-1] == (1997, 12, 23, 9, 0, 0), (1997, 12, 23, 9, 0, 0), l[-1] 107 print 108 109 qualifiers = [ 110 ("WEEKLY", {"interval" : 1}) 111 ] 112 113 l = order_qualifiers(qualifiers) 114 show(l) 115 dt = (1997, 9, 2, 9, 0, 0) 116 l = get_datetime_structure(dt) 117 show(l) 118 l = combine_datetime_with_qualifiers(dt, qualifiers) 119 show(l) 120 121 s = get_selector(dt, qualifiers) 122 l = s.materialise(dt, (1997, 12, 24, 0, 0, 0)) 123 print len(l) == 17, 17, len(l) 124 print l[0] == (1997, 9, 2, 9, 0, 0), (1997, 9, 2, 9, 0, 0), l[0] 125 print l[-1] == (1997, 12, 23, 9, 0, 0), (1997, 12, 23, 9, 0, 0), l[-1] 126 print 127 128 qualifiers = [ 129 ("DAILY", {"interval" : 10}) 130 ] 131 132 l = order_qualifiers(qualifiers) 133 show(l) 134 dt = (1997, 9, 2, 9, 0, 0) 135 l = get_datetime_structure(dt) 136 show(l) 137 l = combine_datetime_with_qualifiers(dt, qualifiers) 138 show(l) 139 140 s = get_selector(dt, qualifiers) 141 l = s.materialise(dt, (1997, 12, 24, 0, 0, 0), 5) 142 print len(l) == 5, 5, len(l) 143 print l[0] == (1997, 9, 2, 9, 0, 0), (1997, 9, 2, 9, 0, 0), l[0] 144 print l[-1] == (1997, 10, 12, 9, 0, 0), (1997, 10, 12, 9, 0, 0), l[-1] 145 print 146 147 qualifiers = [ 148 ("YEARLY", {"interval" : 1}), 149 ("BYMONTH", {"values" : [1]}), 150 ("BYDAY", {"values" : [(1, None), (2, None), (3, None), (4, None), (5, None), (6, None), (7, None)]}) 151 ] 152 153 l = order_qualifiers(qualifiers) 154 show(l) 155 dt = (1998, 1, 1, 9, 0, 0) 156 l = get_datetime_structure(dt) 157 show(l) 158 l = combine_datetime_with_qualifiers(dt, qualifiers) 159 show(l) 160 161 s = get_selector(dt, qualifiers) 162 l = s.materialise(dt, (2000, 1, 31, 14, 0, 0)) 163 print len(l) == 93, 93, len(l) 164 print l[0] == (1998, 1, 1, 9, 0, 0), (1998, 1, 1, 9, 0, 0), l[0] 165 print l[-1] == (2000, 1, 31, 9, 0, 0), (2000, 1, 31, 9, 0, 0), l[-1] 166 print 167 168 qualifiers = [ 169 ("DAILY", {"interval" : 1}), 170 ("BYMONTH", {"values" : [1]}) 171 ] 172 173 l = order_qualifiers(qualifiers) 174 show(l) 175 dt = (1998, 1, 1, 9, 0, 0) 176 l = get_datetime_structure(dt) 177 show(l) 178 l = combine_datetime_with_qualifiers(dt, qualifiers) 179 show(l) 180 181 s = get_selector(dt, qualifiers) 182 l = s.materialise(dt, (2000, 1, 31, 14, 0, 0)) 183 print len(l) == 93, 93, len(l) 184 print l[0] == (1998, 1, 1, 9, 0, 0), (1998, 1, 1, 9, 0, 0), l[0] 185 print l[-1] == (2000, 1, 31, 9, 0, 0), (2000, 1, 31, 9, 0, 0), l[-1] 186 print 187 188 qualifiers = [ 189 ("WEEKLY", {"interval" : 1}) 190 ] 191 192 l = order_qualifiers(qualifiers) 193 show(l) 194 dt = (1997, 9, 2, 9, 0, 0) 195 l = get_datetime_structure(dt) 196 show(l) 197 l = combine_datetime_with_qualifiers(dt, qualifiers) 198 show(l) 199 200 s = get_selector(dt, qualifiers) 201 l = s.materialise(dt, (1997, 12, 24, 0, 0, 0), 10) 202 print len(l) == 10, 10, len(l) 203 print l[0] == (1997, 9, 2, 9, 0, 0), (1997, 9, 2, 9, 0, 0), l[0] 204 print l[-1] == (1997, 11, 4, 9, 0, 0), (1997, 11, 4, 9, 0, 0), l[-1] 205 print 206 207 qualifiers = [ 208 ("WEEKLY", {"interval" : 1}) 209 ] 210 211 l = order_qualifiers(qualifiers) 212 show(l) 213 dt = (1997, 9, 2, 9, 0, 0) 214 l = get_datetime_structure(dt) 215 show(l) 216 l = combine_datetime_with_qualifiers(dt, qualifiers) 217 show(l) 218 219 s = get_selector(dt, qualifiers) 220 l = s.materialise(dt, (1997, 12, 24, 0, 0, 0)) 221 print len(l) == 17, 17, len(l) 222 print l[0] == (1997, 9, 2, 9, 0, 0), (1997, 9, 2, 9, 0, 0), l[0] 223 print l[-1] == (1997, 12, 23, 9, 0, 0), (1997, 12, 23, 9, 0, 0), l[-1] 224 print 225 226 qualifiers = [ 227 ("WEEKLY", {"interval" : 2}) 228 ] 229 230 l = order_qualifiers(qualifiers) 231 show(l) 232 dt = (1997, 9, 2, 9, 0, 0) 233 l = get_datetime_structure(dt) 234 show(l) 235 l = combine_datetime_with_qualifiers(dt, qualifiers) 236 show(l) 237 238 s = get_selector(dt, qualifiers) 239 l = s.materialise(dt, (1998, 2, 20, 0, 0, 0)) 240 print len(l) == 13, 13, len(l) 241 print l[0] == (1997, 9, 2, 9, 0, 0), (1997, 9, 2, 9, 0, 0), l[0] 242 print l[-1] == (1998, 2, 17, 9, 0, 0), (1998, 2, 17, 9, 0, 0), l[-1] 243 print 244 245 qualifiers = [ 246 ("WEEKLY", {"interval" : 1}), 247 ("BYDAY", {"values" : [(2, None), (4, None)]}) 248 ] 249 250 l = order_qualifiers(qualifiers) 251 show(l) 252 dt = (1997, 9, 2, 9, 0, 0) 253 l = get_datetime_structure(dt) 254 show(l) 255 l = combine_datetime_with_qualifiers(dt, qualifiers) 256 show(l) 257 258 s = get_selector(dt, qualifiers) 259 l = s.materialise(dt, (1997, 10, 7, 9, 0, 0)) 260 print len(l) == 10, 10, len(l) 261 print l[0] == (1997, 9, 2, 9, 0, 0), (1997, 9, 2, 9, 0, 0), l[0] 262 print l[-1] == (1997, 10, 2, 9, 0, 0), (1997, 10, 2, 9, 0, 0), l[-1] 263 print 264 265 qualifiers = [ 266 ("WEEKLY", {"interval" : 1}), 267 ("BYDAY", {"values" : [(2, None), (4, None)]}) 268 ] 269 270 l = order_qualifiers(qualifiers) 271 show(l) 272 dt = (1997, 9, 2, 9, 0, 0) 273 l = get_datetime_structure(dt) 274 show(l) 275 l = combine_datetime_with_qualifiers(dt, qualifiers) 276 show(l) 277 278 s = get_selector(dt, qualifiers) 279 l = s.materialise(dt, (1997, 12, 24, 0, 0, 0), 10) 280 print len(l) == 10, 10, len(l) 281 print l[0] == (1997, 9, 2, 9, 0, 0), (1997, 9, 2, 9, 0, 0), l[0] 282 print l[-1] == (1997, 10, 2, 9, 0, 0), (1997, 10, 2, 9, 0, 0), l[-1] 283 print 284 285 qualifiers = [ 286 ("WEEKLY", {"interval" : 2}), 287 ("BYDAY", {"values" : [(1, None), (3, None), (5, None)]}) 288 ] 289 290 l = order_qualifiers(qualifiers) 291 show(l) 292 dt = (1997, 9, 1, 9, 0, 0) 293 l = get_datetime_structure(dt) 294 show(l) 295 l = combine_datetime_with_qualifiers(dt, qualifiers) 296 show(l) 297 298 s = get_selector(dt, qualifiers) 299 l = s.materialise(dt, (1997, 12, 24, 0, 0, 0)) 300 print len(l) == 25, 25, len(l) 301 print l[0] == (1997, 9, 1, 9, 0, 0), (1997, 9, 1, 9, 0, 0), l[0] 302 print l[-1] == (1997, 12, 22, 9, 0, 0), (1997, 12, 22, 9, 0, 0), l[-1] 303 print 304 305 qualifiers = [ 306 ("WEEKLY", {"interval" : 2}), 307 ("BYDAY", {"values" : [(2, None), (4, None)]}) 308 ] 309 310 l = order_qualifiers(qualifiers) 311 show(l) 312 dt = (1997, 9, 2, 9, 0, 0) 313 l = get_datetime_structure(dt) 314 show(l) 315 l = combine_datetime_with_qualifiers(dt, qualifiers) 316 show(l) 317 318 s = get_selector(dt, qualifiers) 319 l = s.materialise(dt, (1997, 12, 24, 0, 0, 0), 8) 320 print len(l) == 8, 8, len(l) 321 print l[0] == (1997, 9, 2, 9, 0, 0), (1997, 9, 2, 9, 0, 0), l[0] 322 print l[-1] == (1997, 10, 16, 9, 0, 0), (1997, 10, 16, 9, 0, 0), l[-1] 323 print 324 325 qualifiers = [ 326 ("MONTHLY", {"interval" : 1}), 327 ("BYDAY", {"values" : [(5, 1)]}) 328 ] 329 330 l = order_qualifiers(qualifiers) 331 show(l) 332 dt = (1997, 9, 5, 9, 0, 0) 333 l = get_datetime_structure(dt) 334 show(l) 335 l = combine_datetime_with_qualifiers(dt, qualifiers) 336 show(l) 337 338 s = get_selector(dt, qualifiers) 339 l = s.materialise(dt, (1998, 12, 24, 0, 0, 0), 10) 340 print len(l) == 10, 10, len(l) 341 print l[0] == (1997, 9, 5, 9, 0, 0), (1997, 9, 5, 9, 0, 0), l[0] 342 print l[-1] == (1998, 6, 5, 9, 0, 0), (1998, 6, 5, 9, 0, 0), l[-1] 343 print 344 345 qualifiers = [ 346 ("MONTHLY", {"interval" : 1}), 347 ("BYDAY", {"values" : [(5, 1)]}) 348 ] 349 350 l = order_qualifiers(qualifiers) 351 show(l) 352 dt = (1997, 9, 5, 9, 0, 0) 353 l = get_datetime_structure(dt) 354 show(l) 355 l = combine_datetime_with_qualifiers(dt, qualifiers) 356 show(l) 357 358 s = get_selector(dt, qualifiers) 359 l = s.materialise(dt, (1997, 12, 24, 0, 0, 0)) 360 print len(l) == 4, 4, len(l) 361 print l[0] == (1997, 9, 5, 9, 0, 0), (1997, 9, 5, 9, 0, 0), l[0] 362 print l[-1] == (1997, 12, 5, 9, 0, 0), (1997, 12, 5, 9, 0, 0), l[-1] 363 print 364 365 qualifiers = [ 366 ("MONTHLY", {"interval" : 2}), 367 ("BYDAY", {"values" : [(7, 1), (7, -1)]}) 368 ] 369 370 l = order_qualifiers(qualifiers) 371 show(l) 372 dt = (1997, 9, 7, 9, 0, 0) 373 l = get_datetime_structure(dt) 374 show(l) 375 l = combine_datetime_with_qualifiers(dt, qualifiers) 376 show(l) 377 378 s = get_selector(dt, qualifiers) 379 l = s.materialise(dt, (1998, 12, 24, 0, 0, 0), 10) 380 print len(l) == 10, 10, len(l) 381 print l[0] == (1997, 9, 7, 9, 0, 0), (1997, 9, 7, 9, 0, 0), l[0] 382 print l[-1] == (1998, 5, 31, 9, 0, 0), (1998, 5, 31, 9, 0, 0), l[-1] 383 print 384 385 qualifiers = [ 386 ("MONTHLY", {"interval" : 1}), 387 ("BYDAY", {"values" : [(1, -2)]}) 388 ] 389 390 l = order_qualifiers(qualifiers) 391 show(l) 392 dt = (1997, 9, 22, 9, 0, 0) 393 l = get_datetime_structure(dt) 394 show(l) 395 l = combine_datetime_with_qualifiers(dt, qualifiers) 396 show(l) 397 398 s = get_selector(dt, qualifiers) 399 l = s.materialise(dt, (1998, 12, 24, 0, 0, 0), 6) 400 print len(l) == 6, 6, len(l) 401 print l[0] == (1997, 9, 22, 9, 0, 0), (1997, 9, 22, 9, 0, 0), l[0] 402 print l[-1] == (1998, 2, 16, 9, 0, 0), (1998, 2, 16, 9, 0, 0), l[-1] 403 print 404 405 qualifiers = [ 406 ("MONTHLY", {"interval" : 1}), 407 ("BYMONTHDAY", {"values" : [-3]}) 408 ] 409 410 l = order_qualifiers(qualifiers) 411 show(l) 412 dt = (1997, 9, 28, 9, 0, 0) 413 l = get_datetime_structure(dt) 414 show(l) 415 l = combine_datetime_with_qualifiers(dt, qualifiers) 416 show(l) 417 418 s = get_selector(dt, qualifiers) 419 l = s.materialise(dt, (1998, 12, 24, 0, 0, 0), 6) 420 print len(l) == 6, 6, len(l) 421 print l[0] == (1997, 9, 28, 9, 0, 0), (1997, 9, 28, 9, 0, 0), l[0] 422 print l[-1] == (1998, 2, 26, 9, 0, 0), (1998, 2, 26, 9, 0, 0), l[-1] 423 print 424 425 qualifiers = [ 426 ("MONTHLY", {"interval" : 1}), 427 ("BYMONTHDAY", {"values" : [2, 15]}) 428 ] 429 430 l = order_qualifiers(qualifiers) 431 show(l) 432 dt = (1997, 9, 2, 9, 0, 0) 433 l = get_datetime_structure(dt) 434 show(l) 435 l = combine_datetime_with_qualifiers(dt, qualifiers) 436 show(l) 437 438 s = get_selector(dt, qualifiers) 439 l = s.materialise(dt, (1998, 12, 24, 0, 0, 0), 10) 440 print len(l) == 10, 10, len(l) 441 print l[0] == (1997, 9, 2, 9, 0, 0), (1997, 9, 2, 9, 0, 0), l[0] 442 print l[-1] == (1998, 1, 15, 9, 0, 0), (1998, 1, 15, 9, 0, 0), l[-1] 443 print 444 445 qualifiers = [ 446 ("MONTHLY", {"interval" : 1}), 447 ("BYMONTHDAY", {"values" : [1, -1]}) 448 ] 449 450 l = order_qualifiers(qualifiers) 451 show(l) 452 dt = (1997, 9, 30, 9, 0, 0) 453 l = get_datetime_structure(dt) 454 show(l) 455 l = combine_datetime_with_qualifiers(dt, qualifiers) 456 show(l) 457 458 s = get_selector(dt, qualifiers) 459 l = s.materialise(dt, (1998, 12, 24, 0, 0, 0), 10) 460 print len(l) == 10, 10, len(l) 461 print l[0] == (1997, 9, 30, 9, 0, 0), (1997, 9, 30, 9, 0, 0), l[0] 462 print l[-1] == (1998, 2, 1, 9, 0, 0), (1998, 2, 1, 9, 0, 0), l[-1] 463 print 464 465 qualifiers = [ 466 ("MONTHLY", {"interval" : 18}), 467 ("BYMONTHDAY", {"values" : [10, 11, 12, 13, 14, 15]}) 468 ] 469 470 l = order_qualifiers(qualifiers) 471 show(l) 472 dt = (1997, 9, 10, 9, 0, 0) 473 l = get_datetime_structure(dt) 474 show(l) 475 l = combine_datetime_with_qualifiers(dt, qualifiers) 476 show(l) 477 478 s = get_selector(dt, qualifiers) 479 l = s.materialise(dt, (1999, 12, 24, 0, 0, 0), 10) 480 print len(l) == 10, 10, len(l) 481 print l[0] == (1997, 9, 10, 9, 0, 0), (1997, 9, 10, 9, 0, 0), l[0] 482 print l[-1] == (1999, 3, 13, 9, 0, 0), (1999, 3, 13, 9, 0, 0), l[-1] 483 print 484 485 qualifiers = [ 486 ("MONTHLY", {"interval" : 2}), 487 ("BYDAY", {"values" : [(2, None)]}) 488 ] 489 490 l = order_qualifiers(qualifiers) 491 show(l) 492 dt = (1997, 9, 2, 9, 0, 0) 493 l = get_datetime_structure(dt) 494 show(l) 495 l = combine_datetime_with_qualifiers(dt, qualifiers) 496 show(l) 497 498 s = get_selector(dt, qualifiers) 499 l = s.materialise(dt, (1998, 4, 1, 0, 0, 0)) 500 print len(l) == 18, 18, len(l) 501 print l[0] == (1997, 9, 2, 9, 0, 0), (1997, 9, 2, 9, 0, 0), l[0] 502 print l[-1] == (1998, 3, 31, 9, 0, 0), (1998, 3, 31, 9, 0, 0), l[-1] 503 print 504 505 qualifiers = [ 506 ("YEARLY", {"interval" : 1}), 507 ("BYMONTH", {"values" : [6, 7]}) 508 ] 509 510 l = order_qualifiers(qualifiers) 511 show(l) 512 dt = (1997, 6, 10, 9, 0, 0) 513 l = get_datetime_structure(dt) 514 show(l) 515 l = combine_datetime_with_qualifiers(dt, qualifiers) 516 show(l) 517 518 s = get_selector(dt, qualifiers) 519 l = s.materialise(dt, (2001, 12, 24, 0, 0, 0), 10) 520 print len(l) == 10, 10, len(l) 521 print l[0] == (1997, 6, 10, 9, 0, 0), (1997, 6, 10, 9, 0, 0), l[0] 522 print l[-1] == (2001, 7, 10, 9, 0, 0), (2001, 7, 10, 9, 0, 0), l[-1] 523 print 524 525 qualifiers = [ 526 ("YEARLY", {"interval" : 2}), 527 ("BYMONTH", {"values" : [1, 2, 3]}) 528 ] 529 530 l = order_qualifiers(qualifiers) 531 show(l) 532 dt = (1997, 3, 10, 9, 0, 0) 533 l = get_datetime_structure(dt) 534 show(l) 535 l = combine_datetime_with_qualifiers(dt, qualifiers) 536 show(l) 537 538 s = get_selector(dt, qualifiers) 539 l = s.materialise(dt, (2003, 12, 24, 0, 0, 0), 10) 540 print len(l) == 10, 10, len(l) 541 print l[0] == (1997, 3, 10, 9, 0, 0), (1997, 3, 10, 9, 0, 0), l[0] 542 print l[-1] == (2003, 3, 10, 9, 0, 0), (2003, 3, 10, 9, 0, 0), l[-1] 543 print 544 545 qualifiers = [ 546 ("YEARLY", {"interval" : 3}), 547 ("BYYEARDAY", {"values" : [1, 100, 200]}) 548 ] 549 550 l = order_qualifiers(qualifiers) 551 show(l) 552 dt = (1997, 1, 1, 9, 0, 0) 553 l = get_datetime_structure(dt) 554 show(l) 555 l = combine_datetime_with_qualifiers(dt, qualifiers) 556 show(l) 557 558 s = get_selector(dt, qualifiers) 559 l = s.materialise(dt, (2006, 2, 1, 0, 0, 0), 10) 560 print len(l) == 10, 10, len(l) 561 print l[0] == (1997, 1, 1, 9, 0, 0), (1997, 1, 1, 9, 0, 0), l[0] 562 print l[-1] == (2006, 1, 1, 9, 0, 0), (2006, 1, 1, 9, 0, 0), l[-1] 563 print 564 565 qualifiers = [ 566 ("YEARLY", {"interval" : 1}), 567 ("BYDAY", {"values" : [(1, 20)]}) 568 ] 569 570 l = order_qualifiers(qualifiers) 571 show(l) 572 dt = (1997, 5, 19, 9, 0, 0) 573 l = get_datetime_structure(dt) 574 show(l) 575 l = combine_datetime_with_qualifiers(dt, qualifiers) 576 show(l) 577 578 s = get_selector(dt, qualifiers) 579 l = s.materialise(dt, (1999, 12, 24, 0, 0, 0)) 580 print len(l) == 3, 3, len(l) 581 print l[0] == (1997, 5, 19, 9, 0, 0), (1997, 5, 19, 9, 0, 0), l[0] 582 print l[-1] == (1999, 5, 17, 9, 0, 0), (1999, 5, 17, 9, 0, 0), l[-1] 583 print 584 585 """ 586 qualifiers = [ 587 ("YEARLY", {"interval" : 1}), 588 ("BYWEEKNO", {"values" : [20]}), 589 ("BYDAY", {"values" : [(1, None)]}) 590 ] 591 592 l = order_qualifiers(qualifiers) 593 show(l) 594 dt = (1997, 5, 12, 9, 0, 0) 595 l = get_datetime_structure(dt) 596 show(l) 597 l = combine_datetime_with_qualifiers(dt, qualifiers) 598 show(l) 599 600 s = get_selector(dt, qualifiers) 601 l = s.materialise(dt, (1999, 12, 24, 0, 0, 0)) 602 print len(l) == 3, 3, len(l) 603 print l[0] == (1997, 5, 12, 9, 0, 0), (1997, 5, 12, 9, 0, 0), l[0] 604 print l[-1] == (1999, 5, 17, 9, 0, 0), (1999, 5, 17, 9, 0, 0), l[-1] 605 print 606 """ 607 608 qualifiers = [ 609 ("YEARLY", {"interval" : 1}), 610 ("BYMONTH", {"values" : [3]}), 611 ("BYDAY", {"values" : [(4, None)]}) 612 ] 613 614 l = order_qualifiers(qualifiers) 615 show(l) 616 dt = (1997, 3, 13, 9, 0, 0) 617 l = get_datetime_structure(dt) 618 show(l) 619 l = combine_datetime_with_qualifiers(dt, qualifiers) 620 show(l) 621 622 s = get_selector(dt, qualifiers) 623 l = s.materialise(dt, (1999, 12, 24, 0, 0, 0)) 624 print len(l) == 11, 11, len(l) 625 print l[0] == (1997, 3, 13, 9, 0, 0), (1997, 3, 13, 9, 0, 0), l[0] 626 print l[-1] == (1999, 3, 25, 9, 0, 0), (1999, 3, 25, 9, 0, 0), l[-1] 627 print 628 629 qualifiers = [ 630 ("YEARLY", {"interval" : 1}), 631 ("BYMONTH", {"values" : [6, 7, 8]}), 632 ("BYDAY", {"values" : [(4, None)]}) 633 ] 634 635 l = order_qualifiers(qualifiers) 636 show(l) 637 dt = (1997, 6, 5, 9, 0, 0) 638 l = get_datetime_structure(dt) 639 show(l) 640 l = combine_datetime_with_qualifiers(dt, qualifiers) 641 show(l) 642 643 s = get_selector(dt, qualifiers) 644 l = s.materialise(dt, (1999, 12, 24, 0, 0, 0)) 645 print len(l) == 39, 39, len(l) 646 print l[0] == (1997, 6, 5, 9, 0, 0), (1997, 6, 5, 9, 0, 0), l[0] 647 print l[-1] == (1999, 8, 26, 9, 0, 0), (1999, 8, 26, 9, 0, 0), l[-1] 648 print 649 650 qualifiers = [ 651 ("MONTHLY", {"interval" : 1}), 652 ("BYMONTHDAY", {"values" : [13]}), 653 ("BYDAY", {"values" : [(5, None)]}) 654 ] 655 656 l = order_qualifiers(qualifiers) 657 show(l) 658 dt = (1997, 9, 2, 9, 0, 0) 659 l = get_datetime_structure(dt) 660 show(l) 661 l = combine_datetime_with_qualifiers(dt, qualifiers) 662 show(l) 663 664 s = get_selector(dt, qualifiers) 665 l = s.materialise(dt, (2000, 12, 24, 0, 0, 0)) 666 print len(l) == 5, 5, len(l) 667 print l[0] == (1998, 2, 13, 9, 0, 0), (1998, 2, 13, 9, 0, 0), l[0] 668 print l[-1] == (2000, 10, 13, 9, 0, 0), (2000, 10, 13, 9, 0, 0), l[-1] 669 print 670 671 qualifiers = [ 672 ("MONTHLY", {"interval" : 1}), 673 ("BYMONTHDAY", {"values" : [7, 8, 9, 10, 11, 12, 13]}), 674 ("BYDAY", {"values" : [(6, None)]}) 675 ] 676 677 l = order_qualifiers(qualifiers) 678 show(l) 679 dt = (1997, 9, 13, 9, 0, 0) 680 l = get_datetime_structure(dt) 681 show(l) 682 l = combine_datetime_with_qualifiers(dt, qualifiers) 683 show(l) 684 685 s = get_selector(dt, qualifiers) 686 l = s.materialise(dt, (1998, 6, 30, 0, 0, 0)) 687 print len(l) == 10, 10, len(l) 688 print l[0] == (1997, 9, 13, 9, 0, 0), (1997, 9, 13, 9, 0, 0), l[0] 689 print l[-1] == (1998, 6, 13, 9, 0, 0), (1998, 6, 13, 9, 0, 0), l[-1] 690 print 691 692 qualifiers = [ 693 ("YEARLY", {"interval" : 4}), 694 ("BYMONTH", {"values" : [11]}), 695 ("BYMONTHDAY", {"values" : [2, 3, 4, 5, 6, 7, 8]}), 696 ("BYDAY", {"values" : [(2, None)]}) 697 ] 698 699 l = order_qualifiers(qualifiers) 700 show(l) 701 dt = (1996, 11, 5, 9, 0, 0) 702 l = get_datetime_structure(dt) 703 show(l) 704 l = combine_datetime_with_qualifiers(dt, qualifiers) 705 show(l) 706 707 s = get_selector(dt, qualifiers) 708 l = s.materialise(dt, (2004, 12, 24, 0, 0, 0)) 709 print len(l) == 3, 3, len(l) 710 print l[0] == (1996, 11, 5, 9, 0, 0), (1996, 11, 5, 9, 0, 0), l[0] 711 print l[-1] == (2004, 11, 2, 9, 0, 0), (2004, 11, 2, 9, 0, 0), l[-1] 712 print 713 714 qualifiers = [ 715 ("MONTHLY", {"interval" : 1}), 716 ("BYDAY", {"values" : [(2, None), (3, None), (4, None)]}) 717 ] 718 719 l = order_qualifiers(qualifiers) 720 show(l) 721 dt = (1997, 9, 4, 9, 0, 0) 722 l = get_datetime_structure(dt) 723 show(l) 724 l = combine_datetime_with_qualifiers(dt, qualifiers) 725 show(l) 726 727 s = get_selector(dt, qualifiers) 728 l = s.materialise(dt, (1997, 12, 24, 0, 0, 0), 3, [3]) 729 print len(l) == 3, 3, len(l) 730 print l[0] == (1997, 9, 4, 9, 0, 0), (1997, 9, 4, 9, 0, 0), l[0] 731 print l[-1] == (1997, 11, 6, 9, 0, 0), (1997, 11, 6, 9, 0, 0), l[-1] 732 print 733 734 l2 = l 735 736 qualifiers = [ 737 ("MONTHLY", {"interval" : 1}), 738 ("BYDAY", {"values" : [(1, None), (2, None), (3, None), (4, None), (5, None)]}) 739 ] 740 741 l = order_qualifiers(qualifiers) 742 show(l) 743 dt = (1997, 9, 29, 9, 0, 0) 744 l = get_datetime_structure(dt) 745 show(l) 746 l = combine_datetime_with_qualifiers(dt, qualifiers) 747 show(l) 748 749 s = get_selector(dt, qualifiers) 750 l = s.materialise(dt, (1998, 4, 1, 0, 0, 0), None, [-2]) 751 print len(l) == 7, 7, len(l) 752 print l[0] == (1997, 9, 29, 9, 0, 0), (1997, 9, 29, 9, 0, 0), l[0] 753 print l[-1] == (1998, 3, 30, 9, 0, 0), (1998, 3, 30, 9, 0, 0), l[-1] 754 print 755 756 # vim: tabstop=4 expandtab shiftwidth=4