imip-agent

Annotated tests/qualifiers.py

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