Exemple #1
0
def test_friday_thirteenth():
    import uICAL

    rr = uICAL.RRule("FREQ=MONTHLY;BYDAY=FR;BYMONTHDAY=13", "19700101T090000")
    
    year = None
    for i in range(10000):
        assert rr.next() == True
        now = rr.now()
        if year:
            assert year <= now[0], "Year decreased after %d occureences" % i
        year = now[0]
        assert now[2] == 13
Exemple #2
0
def list_rrule_no_tz(rrule, dtstart, begin, end, exdates, maxres):
    import uICAL
    rule = rrule.split(':', 1)[1]
    start = dtstart.split(':', 1)[1]

    excludes = [ex.split(':', 1)[1] for ex in exdates]

    rr = uICAL.RRule(rule, start, begin=begin, end=end, exclude=excludes)

    results = []
    while rr.next():
        results.append("%04d%02d%02dT%02d%02d%02d" % rr.now())
        if len(results) == maxres:
            break
    return results
Exemple #3
0
        attrs[k] = v
    return attrs


def attrs_as_str(attrs):
    if not attrs:
        return ''
    return ';' + ';'.join(['%s:%s' % (k, v) for k, v in attrs.items()])


for arg in sys.argv[1:]:
    key, value = arg.split(':', 1)
    if ';' in key:
        key, attrs = key.split(';', 1)
    if key == 'RRULE':
        rrule = value
    if key == 'DTSTART':
        dtstart = value

rr = uICAL.RRule(rrule, dtstart)

next = rr.next()
print()
print('%s' % rr)
print()
print('DTSTART:%s' % dtstart)
print('RRULE:%s' % rrule)
while next:
    print(" - %04d%02d%02dT%02d%02d%02d" % rr.now())
    next = rr.next()
Exemple #4
0
def test_begin_end():
    import uICAL

    rr = uICAL.RRule("FREQ=MONTHLY;BYDAY=FR;BYMONTHDAY=13", "19970902T090000", begin="23000101T090000")
    assert rr.next() == True
    assert rr.now() == (2300, 4, 13, 9, 0, 0)