vContent

Annotated tests/qualifiers.py

54:e2841274e1fb
2014-10-09 Paul Boddie Added convenience and support functions for handling iCalendar rule values.
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@54 22
s = get_selector(dt, qualifiers)
paul@43 23
l = s.materialise(dt, (2003, 12, 24))
paul@47 24
print len(l) == 7, 7, len(l)
paul@47 25
print l[0] == (1997, 11, 2), (1997, 11, 2), l[0]
paul@47 26
print l[-1] == (2003, 11, 2), (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@54 45
s = get_selector(dt, qualifiers)
paul@43 46
l = s.materialise(dt, (2003, 12, 24, 0, 0, 0))
paul@47 47
print len(l) == 32, 32, len(l)
paul@47 48
print l[0] == (1997, 1, 11, 8, 30, 0), (1997, 1, 11, 8, 30, 0), l[0]
paul@47 49
print l[-1] == (2003, 1, 25, 9, 30, 0), (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@54 64
s = get_selector(dt, qualifiers)
paul@43 65
l = s.materialise(dt, (1997, 12, 24), 10)
paul@47 66
print len(l) == 10, 10, len(l)
paul@47 67
print l[0] == (1997, 9, 2, 9, 0, 0), (1997, 9, 2, 9, 0, 0), l[0]
paul@47 68
print l[-1] == (1997, 9, 11, 9, 0, 0), (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@54 83
s = get_selector(dt, qualifiers)
paul@43 84
l = s.materialise(dt, (1997, 12, 24, 0, 0, 0))
paul@47 85
print len(l) == 113, 113, len(l)
paul@47 86
print l[0] == (1997, 9, 2, 9, 0, 0), (1997, 9, 2, 9, 0, 0), l[0]
paul@47 87
print l[-1] == (1997, 12, 23, 9, 0, 0), (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@54 102
s = get_selector(dt, qualifiers)
paul@43 103
l = s.materialise(dt, (1997, 12, 24, 0, 0, 0))
paul@47 104
print len(l) == 57, 57, len(l)
paul@47 105
print l[0] == (1997, 9, 2, 9, 0, 0), (1997, 9, 2, 9, 0, 0), l[0]
paul@47 106
print l[-1] == (1997, 12, 23, 9, 0, 0), (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@54 121
s = get_selector(dt, qualifiers)
paul@43 122
l = s.materialise(dt, (1997, 12, 24, 0, 0, 0))
paul@47 123
print len(l) == 17, 17, len(l)
paul@47 124
print l[0] == (1997, 9, 2, 9, 0, 0), (1997, 9, 2, 9, 0, 0), l[0]
paul@47 125
print l[-1] == (1997, 12, 23, 9, 0, 0), (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@54 140
s = get_selector(dt, qualifiers)
paul@43 141
l = s.materialise(dt, (1997, 12, 24, 0, 0, 0), 5)
paul@47 142
print len(l) == 5, 5, len(l)
paul@47 143
print l[0] == (1997, 9, 2, 9, 0, 0), (1997, 9, 2, 9, 0, 0), l[0]
paul@47 144
print l[-1] == (1997, 10, 12, 9, 0, 0), (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@54 161
s = get_selector(dt, qualifiers)
paul@43 162
l = s.materialise(dt, (2000, 1, 31, 14, 0, 0))
paul@47 163
print len(l) == 93, 93, len(l)
paul@47 164
print l[0] == (1998, 1, 1, 9, 0, 0), (1998, 1, 1, 9, 0, 0), l[0]
paul@47 165
print l[-1] == (2000, 1, 31, 9, 0, 0), (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@54 181
s = get_selector(dt, qualifiers)
paul@43 182
l = s.materialise(dt, (2000, 1, 31, 14, 0, 0))
paul@47 183
print len(l) == 93, 93, len(l)
paul@47 184
print l[0] == (1998, 1, 1, 9, 0, 0), (1998, 1, 1, 9, 0, 0), l[0]
paul@47 185
print l[-1] == (2000, 1, 31, 9, 0, 0), (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@54 200
s = get_selector(dt, qualifiers)
paul@43 201
l = s.materialise(dt, (1997, 12, 24, 0, 0, 0), 10)
paul@47 202
print len(l) == 10, 10, len(l)
paul@47 203
print l[0] == (1997, 9, 2, 9, 0, 0), (1997, 9, 2, 9, 0, 0), l[0]
paul@47 204
print l[-1] == (1997, 11, 4, 9, 0, 0), (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@54 219
s = get_selector(dt, qualifiers)
paul@43 220
l = s.materialise(dt, (1997, 12, 24, 0, 0, 0))
paul@47 221
print len(l) == 17, 17, len(l)
paul@47 222
print l[0] == (1997, 9, 2, 9, 0, 0), (1997, 9, 2, 9, 0, 0), l[0]
paul@47 223
print l[-1] == (1997, 12, 23, 9, 0, 0), (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@54 238
s = get_selector(dt, qualifiers)
paul@43 239
l = s.materialise(dt, (1998, 2, 20, 0, 0, 0))
paul@47 240
print len(l) == 13, 13, len(l)
paul@47 241
print l[0] == (1997, 9, 2, 9, 0, 0), (1997, 9, 2, 9, 0, 0), l[0]
paul@47 242
print l[-1] == (1998, 2, 17, 9, 0, 0), (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@54 258
s = get_selector(dt, qualifiers)
paul@43 259
l = s.materialise(dt, (1997, 10, 7, 9, 0, 0))
paul@47 260
print len(l) == 10, 10, len(l)
paul@47 261
print l[0] == (1997, 9, 2, 9, 0, 0), (1997, 9, 2, 9, 0, 0), l[0]
paul@47 262
print l[-1] == (1997, 10, 2, 9, 0, 0), (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@54 278
s = get_selector(dt, qualifiers)
paul@43 279
l = s.materialise(dt, (1997, 12, 24, 0, 0, 0), 10)
paul@47 280
print len(l) == 10, 10, len(l)
paul@47 281
print l[0] == (1997, 9, 2, 9, 0, 0), (1997, 9, 2, 9, 0, 0), l[0]
paul@47 282
print l[-1] == (1997, 10, 2, 9, 0, 0), (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@54 298
s = get_selector(dt, qualifiers)
paul@43 299
l = s.materialise(dt, (1997, 12, 24, 0, 0, 0))
paul@47 300
print len(l) == 25, 25, len(l)
paul@47 301
print l[0] == (1997, 9, 1, 9, 0, 0), (1997, 9, 1, 9, 0, 0), l[0]
paul@47 302
print l[-1] == (1997, 12, 22, 9, 0, 0), (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@54 318
s = get_selector(dt, qualifiers)
paul@43 319
l = s.materialise(dt, (1997, 12, 24, 0, 0, 0), 8)
paul@47 320
print len(l) == 8, 8, len(l)
paul@47 321
print l[0] == (1997, 9, 2, 9, 0, 0), (1997, 9, 2, 9, 0, 0), l[0]
paul@47 322
print l[-1] == (1997, 10, 16, 9, 0, 0), (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@47 327
    ("BYDAY", {"values" : [(5, 1)]})
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@54 338
s = get_selector(dt, qualifiers)
paul@43 339
l = s.materialise(dt, (1998, 12, 24, 0, 0, 0), 10)
paul@47 340
print len(l) == 10, 10, len(l)
paul@47 341
print l[0] == (1997, 9, 5, 9, 0, 0), (1997, 9, 5, 9, 0, 0), l[0]
paul@47 342
print l[-1] == (1998, 6, 5, 9, 0, 0), (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@47 347
    ("BYDAY", {"values" : [(5, 1)]})
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@54 358
s = get_selector(dt, qualifiers)
paul@43 359
l = s.materialise(dt, (1997, 12, 24, 0, 0, 0))
paul@47 360
print len(l) == 4, 4, len(l)
paul@47 361
print l[0] == (1997, 9, 5, 9, 0, 0), (1997, 9, 5, 9, 0, 0), l[0]
paul@47 362
print l[-1] == (1997, 12, 5, 9, 0, 0), (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@47 367
    ("BYDAY", {"values" : [(7, 1), (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@54 378
s = get_selector(dt, qualifiers)
paul@43 379
l = s.materialise(dt, (1998, 12, 24, 0, 0, 0), 10)
paul@47 380
print len(l) == 10, 10, len(l)
paul@47 381
print l[0] == (1997, 9, 7, 9, 0, 0), (1997, 9, 7, 9, 0, 0), l[0]
paul@47 382
print l[-1] == (1998, 5, 31, 9, 0, 0), (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@54 398
s = get_selector(dt, qualifiers)
paul@43 399
l = s.materialise(dt, (1998, 12, 24, 0, 0, 0), 6)
paul@47 400
print len(l) == 6, 6, len(l)
paul@47 401
print l[0] == (1997, 9, 22, 9, 0, 0), (1997, 9, 22, 9, 0, 0), l[0]
paul@47 402
print l[-1] == (1998, 2, 16, 9, 0, 0), (1998, 2, 16, 9, 0, 0), l[-1]
paul@42 403
print
paul@42 404
paul@43 405
qualifiers = [
paul@43 406
    ("MONTHLY", {"interval" : 1}),
paul@43 407
    ("BYMONTHDAY", {"values" : [-3]})
paul@43 408
    ]
paul@43 409
paul@43 410
l = order_qualifiers(qualifiers)
paul@43 411
show(l)
paul@43 412
dt = (1997, 9, 28, 9, 0, 0)
paul@43 413
l = get_datetime_structure(dt)
paul@43 414
show(l)
paul@43 415
l = combine_datetime_with_qualifiers(dt, qualifiers)
paul@43 416
show(l)
paul@43 417
paul@54 418
s = get_selector(dt, qualifiers)
paul@43 419
l = s.materialise(dt, (1998, 12, 24, 0, 0, 0), 6)
paul@47 420
print len(l) == 6, 6, len(l)
paul@47 421
print l[0] == (1997, 9, 28, 9, 0, 0), (1997, 9, 28, 9, 0, 0), l[0]
paul@47 422
print l[-1] == (1998, 2, 26, 9, 0, 0), (1998, 2, 26, 9, 0, 0), l[-1]
paul@43 423
print
paul@43 424
paul@43 425
qualifiers = [
paul@43 426
    ("MONTHLY", {"interval" : 1}),
paul@43 427
    ("BYMONTHDAY", {"values" : [2, 15]})
paul@43 428
    ]
paul@43 429
paul@43 430
l = order_qualifiers(qualifiers)
paul@43 431
show(l)
paul@43 432
dt = (1997, 9, 2, 9, 0, 0)
paul@43 433
l = get_datetime_structure(dt)
paul@43 434
show(l)
paul@43 435
l = combine_datetime_with_qualifiers(dt, qualifiers)
paul@43 436
show(l)
paul@43 437
paul@54 438
s = get_selector(dt, qualifiers)
paul@43 439
l = s.materialise(dt, (1998, 12, 24, 0, 0, 0), 10)
paul@47 440
print len(l) == 10, 10, len(l)
paul@47 441
print l[0] == (1997, 9, 2, 9, 0, 0), (1997, 9, 2, 9, 0, 0), l[0]
paul@47 442
print l[-1] == (1998, 1, 15, 9, 0, 0), (1998, 1, 15, 9, 0, 0), l[-1]
paul@43 443
print
paul@43 444
paul@43 445
qualifiers = [
paul@43 446
    ("MONTHLY", {"interval" : 1}),
paul@43 447
    ("BYMONTHDAY", {"values" : [1, -1]})
paul@43 448
    ]
paul@43 449
paul@43 450
l = order_qualifiers(qualifiers)
paul@43 451
show(l)
paul@43 452
dt = (1997, 9, 30, 9, 0, 0)
paul@43 453
l = get_datetime_structure(dt)
paul@43 454
show(l)
paul@43 455
l = combine_datetime_with_qualifiers(dt, qualifiers)
paul@43 456
show(l)
paul@43 457
paul@54 458
s = get_selector(dt, qualifiers)
paul@43 459
l = s.materialise(dt, (1998, 12, 24, 0, 0, 0), 10)
paul@47 460
print len(l) == 10, 10, len(l)
paul@47 461
print l[0] == (1997, 9, 30, 9, 0, 0), (1997, 9, 30, 9, 0, 0), l[0]
paul@47 462
print l[-1] == (1998, 2, 1, 9, 0, 0), (1998, 2, 1, 9, 0, 0), l[-1]
paul@43 463
print
paul@43 464
paul@44 465
qualifiers = [
paul@44 466
    ("MONTHLY", {"interval" : 18}),
paul@44 467
    ("BYMONTHDAY", {"values" : [10, 11, 12, 13, 14, 15]})
paul@44 468
    ]
paul@44 469
paul@44 470
l = order_qualifiers(qualifiers)
paul@44 471
show(l)
paul@44 472
dt = (1997, 9, 10, 9, 0, 0)
paul@44 473
l = get_datetime_structure(dt)
paul@44 474
show(l)
paul@44 475
l = combine_datetime_with_qualifiers(dt, qualifiers)
paul@44 476
show(l)
paul@44 477
paul@54 478
s = get_selector(dt, qualifiers)
paul@44 479
l = s.materialise(dt, (1999, 12, 24, 0, 0, 0), 10)
paul@47 480
print len(l) == 10, 10, len(l)
paul@47 481
print l[0] == (1997, 9, 10, 9, 0, 0), (1997, 9, 10, 9, 0, 0), l[0]
paul@47 482
print l[-1] == (1999, 3, 13, 9, 0, 0), (1999, 3, 13, 9, 0, 0), l[-1]
paul@44 483
print
paul@44 484
paul@44 485
qualifiers = [
paul@44 486
    ("MONTHLY", {"interval" : 2}),
paul@44 487
    ("BYDAY", {"values" : [(2, None)]})
paul@44 488
    ]
paul@44 489
paul@44 490
l = order_qualifiers(qualifiers)
paul@44 491
show(l)
paul@44 492
dt = (1997, 9, 2, 9, 0, 0)
paul@44 493
l = get_datetime_structure(dt)
paul@44 494
show(l)
paul@44 495
l = combine_datetime_with_qualifiers(dt, qualifiers)
paul@44 496
show(l)
paul@44 497
paul@54 498
s = get_selector(dt, qualifiers)
paul@44 499
l = s.materialise(dt, (1998, 4, 1, 0, 0, 0))
paul@47 500
print len(l) == 18, 18, len(l)
paul@47 501
print l[0] == (1997, 9, 2, 9, 0, 0), (1997, 9, 2, 9, 0, 0), l[0]
paul@47 502
print l[-1] == (1998, 3, 31, 9, 0, 0), (1998, 3, 31, 9, 0, 0), l[-1]
paul@44 503
print
paul@44 504
paul@44 505
qualifiers = [
paul@44 506
    ("YEARLY", {"interval" : 1}),
paul@44 507
    ("BYMONTH", {"values" : [6, 7]})
paul@44 508
    ]
paul@44 509
paul@44 510
l = order_qualifiers(qualifiers)
paul@44 511
show(l)
paul@44 512
dt = (1997, 6, 10, 9, 0, 0)
paul@44 513
l = get_datetime_structure(dt)
paul@44 514
show(l)
paul@44 515
l = combine_datetime_with_qualifiers(dt, qualifiers)
paul@44 516
show(l)
paul@44 517
paul@54 518
s = get_selector(dt, qualifiers)
paul@44 519
l = s.materialise(dt, (2001, 12, 24, 0, 0, 0), 10)
paul@47 520
print len(l) == 10, 10, len(l)
paul@47 521
print l[0] == (1997, 6, 10, 9, 0, 0), (1997, 6, 10, 9, 0, 0), l[0]
paul@47 522
print l[-1] == (2001, 7, 10, 9, 0, 0), (2001, 7, 10, 9, 0, 0), l[-1]
paul@44 523
print
paul@44 524
paul@44 525
qualifiers = [
paul@44 526
    ("YEARLY", {"interval" : 2}),
paul@44 527
    ("BYMONTH", {"values" : [1, 2, 3]})
paul@44 528
    ]
paul@44 529
paul@44 530
l = order_qualifiers(qualifiers)
paul@44 531
show(l)
paul@44 532
dt = (1997, 3, 10, 9, 0, 0)
paul@44 533
l = get_datetime_structure(dt)
paul@44 534
show(l)
paul@44 535
l = combine_datetime_with_qualifiers(dt, qualifiers)
paul@44 536
show(l)
paul@44 537
paul@54 538
s = get_selector(dt, qualifiers)
paul@44 539
l = s.materialise(dt, (2003, 12, 24, 0, 0, 0), 10)
paul@47 540
print len(l) == 10, 10, len(l)
paul@47 541
print l[0] == (1997, 3, 10, 9, 0, 0), (1997, 3, 10, 9, 0, 0), l[0]
paul@47 542
print l[-1] == (2003, 3, 10, 9, 0, 0), (2003, 3, 10, 9, 0, 0), l[-1]
paul@44 543
print
paul@44 544
paul@45 545
qualifiers = [
paul@45 546
    ("YEARLY", {"interval" : 3}),
paul@45 547
    ("BYYEARDAY", {"values" : [1, 100, 200]})
paul@45 548
    ]
paul@45 549
paul@45 550
l = order_qualifiers(qualifiers)
paul@45 551
show(l)
paul@45 552
dt = (1997, 1, 1, 9, 0, 0)
paul@45 553
l = get_datetime_structure(dt)
paul@45 554
show(l)
paul@45 555
l = combine_datetime_with_qualifiers(dt, qualifiers)
paul@45 556
show(l)
paul@45 557
paul@54 558
s = get_selector(dt, qualifiers)
paul@45 559
l = s.materialise(dt, (2006, 2, 1, 0, 0, 0), 10)
paul@47 560
print len(l) == 10, 10, len(l)
paul@47 561
print l[0] == (1997, 1, 1, 9, 0, 0), (1997, 1, 1, 9, 0, 0), l[0]
paul@47 562
print l[-1] == (2006, 1, 1, 9, 0, 0), (2006, 1, 1, 9, 0, 0), l[-1]
paul@47 563
print
paul@47 564
paul@47 565
qualifiers = [
paul@47 566
    ("YEARLY", {"interval" : 1}),
paul@47 567
    ("BYDAY", {"values" : [(1, 20)]})
paul@47 568
    ]
paul@47 569
paul@47 570
l = order_qualifiers(qualifiers)
paul@47 571
show(l)
paul@47 572
dt = (1997, 5, 19, 9, 0, 0)
paul@47 573
l = get_datetime_structure(dt)
paul@47 574
show(l)
paul@47 575
l = combine_datetime_with_qualifiers(dt, qualifiers)
paul@47 576
show(l)
paul@47 577
paul@54 578
s = get_selector(dt, qualifiers)
paul@47 579
l = s.materialise(dt, (1999, 12, 24, 0, 0, 0))
paul@47 580
print len(l) == 3, 3, len(l)
paul@47 581
print l[0] == (1997, 5, 19, 9, 0, 0), (1997, 5, 19, 9, 0, 0), l[0]
paul@47 582
print l[-1] == (1999, 5, 17, 9, 0, 0), (1999, 5, 17, 9, 0, 0), l[-1]
paul@45 583
print
paul@45 584
paul@48 585
"""
paul@48 586
qualifiers = [
paul@48 587
    ("YEARLY", {"interval" : 1}),
paul@48 588
    ("BYWEEKNO", {"values" : [20]}),
paul@48 589
    ("BYDAY", {"values" : [(1, None)]})
paul@48 590
    ]
paul@48 591
paul@48 592
l = order_qualifiers(qualifiers)
paul@48 593
show(l)
paul@48 594
dt = (1997, 5, 12, 9, 0, 0)
paul@48 595
l = get_datetime_structure(dt)
paul@48 596
show(l)
paul@48 597
l = combine_datetime_with_qualifiers(dt, qualifiers)
paul@48 598
show(l)
paul@48 599
paul@54 600
s = get_selector(dt, qualifiers)
paul@48 601
l = s.materialise(dt, (1999, 12, 24, 0, 0, 0))
paul@48 602
print len(l) == 3, 3, len(l)
paul@48 603
print l[0] == (1997, 5, 12, 9, 0, 0), (1997, 5, 12, 9, 0, 0), l[0]
paul@48 604
print l[-1] == (1999, 5, 17, 9, 0, 0), (1999, 5, 17, 9, 0, 0), l[-1]
paul@48 605
print
paul@48 606
"""
paul@48 607
paul@48 608
qualifiers = [
paul@48 609
    ("YEARLY", {"interval" : 1}),
paul@48 610
    ("BYMONTH", {"values" : [3]}),
paul@48 611
    ("BYDAY", {"values" : [(4, None)]})
paul@48 612
    ]
paul@48 613
paul@48 614
l = order_qualifiers(qualifiers)
paul@48 615
show(l)
paul@48 616
dt = (1997, 3, 13, 9, 0, 0)
paul@48 617
l = get_datetime_structure(dt)
paul@48 618
show(l)
paul@48 619
l = combine_datetime_with_qualifiers(dt, qualifiers)
paul@48 620
show(l)
paul@48 621
paul@54 622
s = get_selector(dt, qualifiers)
paul@48 623
l = s.materialise(dt, (1999, 12, 24, 0, 0, 0))
paul@48 624
print len(l) == 11, 11, len(l)
paul@48 625
print l[0] == (1997, 3, 13, 9, 0, 0), (1997, 3, 13, 9, 0, 0), l[0]
paul@48 626
print l[-1] == (1999, 3, 25, 9, 0, 0), (1999, 3, 25, 9, 0, 0), l[-1]
paul@48 627
print
paul@48 628
paul@48 629
qualifiers = [
paul@48 630
    ("YEARLY", {"interval" : 1}),
paul@48 631
    ("BYMONTH", {"values" : [6, 7, 8]}),
paul@48 632
    ("BYDAY", {"values" : [(4, None)]})
paul@48 633
    ]
paul@48 634
paul@48 635
l = order_qualifiers(qualifiers)
paul@48 636
show(l)
paul@48 637
dt = (1997, 6, 5, 9, 0, 0)
paul@48 638
l = get_datetime_structure(dt)
paul@48 639
show(l)
paul@48 640
l = combine_datetime_with_qualifiers(dt, qualifiers)
paul@48 641
show(l)
paul@48 642
paul@54 643
s = get_selector(dt, qualifiers)
paul@48 644
l = s.materialise(dt, (1999, 12, 24, 0, 0, 0))
paul@48 645
print len(l) == 39, 39, len(l)
paul@48 646
print l[0] == (1997, 6, 5, 9, 0, 0), (1997, 6, 5, 9, 0, 0), l[0]
paul@48 647
print l[-1] == (1999, 8, 26, 9, 0, 0), (1999, 8, 26, 9, 0, 0), l[-1]
paul@48 648
print
paul@48 649
paul@48 650
qualifiers = [
paul@48 651
    ("MONTHLY", {"interval" : 1}),
paul@48 652
    ("BYMONTHDAY", {"values" : [13]}),
paul@48 653
    ("BYDAY", {"values" : [(5, None)]})
paul@48 654
    ]
paul@48 655
paul@48 656
l = order_qualifiers(qualifiers)
paul@48 657
show(l)
paul@48 658
dt = (1997, 9, 2, 9, 0, 0)
paul@48 659
l = get_datetime_structure(dt)
paul@48 660
show(l)
paul@48 661
l = combine_datetime_with_qualifiers(dt, qualifiers)
paul@48 662
show(l)
paul@48 663
paul@54 664
s = get_selector(dt, qualifiers)
paul@48 665
l = s.materialise(dt, (2000, 12, 24, 0, 0, 0))
paul@48 666
print len(l) == 5, 5, len(l)
paul@48 667
print l[0] == (1998, 2, 13, 9, 0, 0), (1998, 2, 13, 9, 0, 0), l[0]
paul@48 668
print l[-1] == (2000, 10, 13, 9, 0, 0), (2000, 10, 13, 9, 0, 0), l[-1]
paul@48 669
print
paul@48 670
paul@48 671
qualifiers = [
paul@48 672
    ("MONTHLY", {"interval" : 1}),
paul@48 673
    ("BYMONTHDAY", {"values" : [7, 8, 9, 10, 11, 12, 13]}),
paul@48 674
    ("BYDAY", {"values" : [(6, None)]})
paul@48 675
    ]
paul@48 676
paul@48 677
l = order_qualifiers(qualifiers)
paul@48 678
show(l)
paul@48 679
dt = (1997, 9, 13, 9, 0, 0)
paul@48 680
l = get_datetime_structure(dt)
paul@48 681
show(l)
paul@48 682
l = combine_datetime_with_qualifiers(dt, qualifiers)
paul@48 683
show(l)
paul@48 684
paul@54 685
s = get_selector(dt, qualifiers)
paul@48 686
l = s.materialise(dt, (1998, 6, 30, 0, 0, 0))
paul@48 687
print len(l) == 10, 10, len(l)
paul@48 688
print l[0] == (1997, 9, 13, 9, 0, 0), (1997, 9, 13, 9, 0, 0), l[0]
paul@48 689
print l[-1] == (1998, 6, 13, 9, 0, 0), (1998, 6, 13, 9, 0, 0), l[-1]
paul@48 690
print
paul@48 691
paul@48 692
qualifiers = [
paul@48 693
    ("YEARLY", {"interval" : 4}),
paul@48 694
    ("BYMONTH", {"values" : [11]}),
paul@48 695
    ("BYMONTHDAY", {"values" : [2, 3, 4, 5, 6, 7, 8]}),
paul@48 696
    ("BYDAY", {"values" : [(2, None)]})
paul@48 697
    ]
paul@48 698
paul@48 699
l = order_qualifiers(qualifiers)
paul@48 700
show(l)
paul@48 701
dt = (1996, 11, 5, 9, 0, 0)
paul@48 702
l = get_datetime_structure(dt)
paul@48 703
show(l)
paul@48 704
l = combine_datetime_with_qualifiers(dt, qualifiers)
paul@48 705
show(l)
paul@48 706
paul@54 707
s = get_selector(dt, qualifiers)
paul@48 708
l = s.materialise(dt, (2004, 12, 24, 0, 0, 0))
paul@48 709
print len(l) == 3, 3, len(l)
paul@48 710
print l[0] == (1996, 11, 5, 9, 0, 0), (1996, 11, 5, 9, 0, 0), l[0]
paul@48 711
print l[-1] == (2004, 11, 2, 9, 0, 0), (2004, 11, 2, 9, 0, 0), l[-1]
paul@48 712
print
paul@48 713
paul@53 714
qualifiers = [
paul@53 715
    ("MONTHLY", {"interval" : 1}),
paul@53 716
    ("BYDAY", {"values" : [(2, None), (3, None), (4, None)]})
paul@53 717
    ]
paul@53 718
paul@53 719
l = order_qualifiers(qualifiers)
paul@53 720
show(l)
paul@53 721
dt = (1997, 9, 4, 9, 0, 0)
paul@53 722
l = get_datetime_structure(dt)
paul@53 723
show(l)
paul@53 724
l = combine_datetime_with_qualifiers(dt, qualifiers)
paul@53 725
show(l)
paul@53 726
paul@54 727
s = get_selector(dt, qualifiers)
paul@53 728
l = s.materialise(dt, (1997, 12, 24, 0, 0, 0), 3, [3])
paul@53 729
print len(l) == 3, 3, len(l)
paul@53 730
print l[0] == (1997, 9, 4, 9, 0, 0), (1997, 9, 4, 9, 0, 0), l[0]
paul@53 731
print l[-1] == (1997, 11, 6, 9, 0, 0), (1997, 11, 6, 9, 0, 0), l[-1]
paul@53 732
print
paul@53 733
paul@53 734
l2 = l
paul@53 735
paul@53 736
qualifiers = [
paul@53 737
    ("MONTHLY", {"interval" : 1}),
paul@53 738
    ("BYDAY", {"values" : [(1, None), (2, None), (3, None), (4, None), (5, None)]})
paul@53 739
    ]
paul@53 740
paul@53 741
l = order_qualifiers(qualifiers)
paul@53 742
show(l)
paul@53 743
dt = (1997, 9, 29, 9, 0, 0)
paul@53 744
l = get_datetime_structure(dt)
paul@53 745
show(l)
paul@53 746
l = combine_datetime_with_qualifiers(dt, qualifiers)
paul@53 747
show(l)
paul@53 748
paul@54 749
s = get_selector(dt, qualifiers)
paul@53 750
l = s.materialise(dt, (1998, 4, 1, 0, 0, 0), None, [-2])
paul@53 751
print len(l) == 7, 7, len(l)
paul@53 752
print l[0] == (1997, 9, 29, 9, 0, 0), (1997, 9, 29, 9, 0, 0), l[0]
paul@53 753
print l[-1] == (1998, 3, 30, 9, 0, 0), (1998, 3, 30, 9, 0, 0), l[-1]
paul@53 754
print
paul@53 755
paul@41 756
# vim: tabstop=4 expandtab shiftwidth=4