blob: 2fb432226ca5461fccbcde74ac5b3ded7fa90c16 [file] [log] [blame]
#!/usr/bin/python
# -*- encoding: utf-8 -*-
from __future__ import unicode_literals
from six import StringIO, BytesIO, PY3
import unittest
import calendar
import base64
import os
# Add build directory to search path
if os.path.exists("build"):
from distutils.util import get_platform
import sys
if sys.version_info >= (3, 2):
s = "build/lib"
else:
s = "build/lib.%s-%.3s" % (get_platform(), sys.version)
s = os.path.join(os.getcwd(), s)
sys.path.insert(0, s)
from dateutil.relativedelta import *
from dateutil.parser import *
from dateutil.easter import *
from dateutil.rrule import *
from dateutil.tz import *
from dateutil import zoneinfo
from datetime import *
class RelativeDeltaTest(unittest.TestCase):
now = datetime(2003, 9, 17, 20, 54, 47, 282310)
today = date(2003, 9, 17)
def testNextMonth(self):
self.assertEqual(self.now+relativedelta(months=+1),
datetime(2003, 10, 17, 20, 54, 47, 282310))
def testNextMonthPlusOneWeek(self):
self.assertEqual(self.now+relativedelta(months=+1, weeks=+1),
datetime(2003, 10, 24, 20, 54, 47, 282310))
def testNextMonthPlusOneWeek10am(self):
self.assertEqual(self.today +
relativedelta(months=+1, weeks=+1, hour=10),
datetime(2003, 10, 24, 10, 0))
def testNextMonthPlusOneWeek10amDiff(self):
self.assertEqual(relativedelta(datetime(2003, 10, 24, 10, 0),
self.today),
relativedelta(months=+1, days=+7, hours=+10))
def testOneMonthBeforeOneYear(self):
self.assertEqual(self.now+relativedelta(years=+1, months=-1),
datetime(2004, 8, 17, 20, 54, 47, 282310))
def testMonthsOfDiffNumOfDays(self):
self.assertEqual(date(2003, 1, 27)+relativedelta(months=+1),
date(2003, 2, 27))
self.assertEqual(date(2003, 1, 31)+relativedelta(months=+1),
date(2003, 2, 28))
self.assertEqual(date(2003, 1, 31)+relativedelta(months=+2),
date(2003, 3, 31))
def testMonthsOfDiffNumOfDaysWithYears(self):
self.assertEqual(date(2000, 2, 28)+relativedelta(years=+1),
date(2001, 2, 28))
self.assertEqual(date(2000, 2, 29)+relativedelta(years=+1),
date(2001, 2, 28))
self.assertEqual(date(1999, 2, 28)+relativedelta(years=+1),
date(2000, 2, 28))
self.assertEqual(date(1999, 3, 1)+relativedelta(years=+1),
date(2000, 3, 1))
self.assertEqual(date(1999, 3, 1)+relativedelta(years=+1),
date(2000, 3, 1))
self.assertEqual(date(2001, 2, 28)+relativedelta(years=-1),
date(2000, 2, 28))
self.assertEqual(date(2001, 3, 1)+relativedelta(years=-1),
date(2000, 3, 1))
def testNextFriday(self):
self.assertEqual(self.today+relativedelta(weekday=FR),
date(2003, 9, 19))
def testNextFridayInt(self):
self.assertEqual(self.today+relativedelta(weekday=calendar.FRIDAY),
date(2003, 9, 19))
def testLastFridayInThisMonth(self):
self.assertEqual(self.today+relativedelta(day=31, weekday=FR(-1)),
date(2003, 9, 26))
def testNextWednesdayIsToday(self):
self.assertEqual(self.today+relativedelta(weekday=WE),
date(2003, 9, 17))
def testNextWenesdayNotToday(self):
self.assertEqual(self.today+relativedelta(days=+1, weekday=WE),
date(2003, 9, 24))
def test15thISOYearWeek(self):
self.assertEqual(date(2003, 1, 1) +
relativedelta(day=4, weeks=+14, weekday=MO(-1)),
date(2003, 4, 7))
def testMillenniumAge(self):
self.assertEqual(relativedelta(self.now, date(2001, 1, 1)),
relativedelta(years=+2, months=+8, days=+16,
hours=+20, minutes=+54, seconds=+47,
microseconds=+282310))
def testJohnAge(self):
self.assertEqual(relativedelta(self.now,
datetime(1978, 4, 5, 12, 0)),
relativedelta(years=+25, months=+5, days=+12,
hours=+8, minutes=+54, seconds=+47,
microseconds=+282310))
def testJohnAgeWithDate(self):
self.assertEqual(relativedelta(self.today,
datetime(1978, 4, 5, 12, 0)),
relativedelta(years=+25, months=+5, days=+11,
hours=+12))
def testYearDay(self):
self.assertEqual(date(2003, 1, 1)+relativedelta(yearday=260),
date(2003, 9, 17))
self.assertEqual(date(2002, 1, 1)+relativedelta(yearday=260),
date(2002, 9, 17))
self.assertEqual(date(2000, 1, 1)+relativedelta(yearday=260),
date(2000, 9, 16))
self.assertEqual(self.today+relativedelta(yearday=261),
date(2003, 9, 18))
def testYearDayBug(self):
# Tests a problem reported by Adam Ryan.
self.assertEqual(date(2010, 1, 1)+relativedelta(yearday=15),
date(2010, 1, 15))
def testNonLeapYearDay(self):
self.assertEqual(date(2003, 1, 1)+relativedelta(nlyearday=260),
date(2003, 9, 17))
self.assertEqual(date(2002, 1, 1)+relativedelta(nlyearday=260),
date(2002, 9, 17))
self.assertEqual(date(2000, 1, 1)+relativedelta(nlyearday=260),
date(2000, 9, 17))
self.assertEqual(self.today+relativedelta(yearday=261),
date(2003, 9, 18))
def test884317(self):
# See https://bugs.launchpad.net/dateutil/+bug/884317
a = relativedelta(second = 2, microsecond = 20)
b = relativedelta(second = 1, microsecond = 10)
c = a-b
self.assertEqual(c.microsecond, b.microsecond)
c = a+b
self.assertEqual(c.microsecond, b.microsecond)
def testMultiplication(self):
self.assertEqual(datetime(2000, 1, 1) + relativedelta(days=1) * 28,
datetime(2000, 1, 29))
self.assertEqual(datetime(2000, 1, 1) + 28 * relativedelta(days=1),
datetime(2000, 1, 29))
def testDivision(self):
self.assertEqual(datetime(2000, 1, 1) + relativedelta(days=28) / 28,
datetime(2000, 1, 2))
class RRuleTest(unittest.TestCase):
def testYearly(self):
self.assertEqual(list(rrule(YEARLY,
count=3,
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 9, 0),
datetime(1998, 9, 2, 9, 0),
datetime(1999, 9, 2, 9, 0)])
def testYearlyInterval(self):
self.assertEqual(list(rrule(YEARLY,
count=3,
interval=2,
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 9, 0),
datetime(1999, 9, 2, 9, 0),
datetime(2001, 9, 2, 9, 0)])
def testYearlyIntervalLarge(self):
self.assertEqual(list(rrule(YEARLY,
count=3,
interval=100,
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 9, 0),
datetime(2097, 9, 2, 9, 0),
datetime(2197, 9, 2, 9, 0)])
def testYearlyByMonth(self):
self.assertEqual(list(rrule(YEARLY,
count=3,
bymonth=(1, 3),
dtstart=parse("19970902T090000"))),
[datetime(1998, 1, 2, 9, 0),
datetime(1998, 3, 2, 9, 0),
datetime(1999, 1, 2, 9, 0)])
def testYearlyByMonthDay(self):
self.assertEqual(list(rrule(YEARLY,
count=3,
bymonthday=(1, 3),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 3, 9, 0),
datetime(1997, 10, 1, 9, 0),
datetime(1997, 10, 3, 9, 0)])
def testYearlyByMonthAndMonthDay(self):
self.assertEqual(list(rrule(YEARLY,
count=3,
bymonth=(1, 3),
bymonthday=(5, 7),
dtstart=parse("19970902T090000"))),
[datetime(1998, 1, 5, 9, 0),
datetime(1998, 1, 7, 9, 0),
datetime(1998, 3, 5, 9, 0)])
def testYearlyByWeekDay(self):
self.assertEqual(list(rrule(YEARLY,
count=3,
byweekday=(TU, TH),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 9, 0),
datetime(1997, 9, 4, 9, 0),
datetime(1997, 9, 9, 9, 0)])
def testYearlyByNWeekDay(self):
self.assertEqual(list(rrule(YEARLY,
count=3,
byweekday=(TU(1), TH(-1)),
dtstart=parse("19970902T090000"))),
[datetime(1997, 12, 25, 9, 0),
datetime(1998, 1, 6, 9, 0),
datetime(1998, 12, 31, 9, 0)])
def testYearlyByNWeekDayLarge(self):
self.assertEqual(list(rrule(YEARLY,
count=3,
byweekday=(TU(3), TH(-3)),
dtstart=parse("19970902T090000"))),
[datetime(1997, 12, 11, 9, 0),
datetime(1998, 1, 20, 9, 0),
datetime(1998, 12, 17, 9, 0)])
def testYearlyByMonthAndWeekDay(self):
self.assertEqual(list(rrule(YEARLY,
count=3,
bymonth=(1, 3),
byweekday=(TU, TH),
dtstart=parse("19970902T090000"))),
[datetime(1998, 1, 1, 9, 0),
datetime(1998, 1, 6, 9, 0),
datetime(1998, 1, 8, 9, 0)])
def testYearlyByMonthAndNWeekDay(self):
self.assertEqual(list(rrule(YEARLY,
count=3,
bymonth=(1, 3),
byweekday=(TU(1), TH(-1)),
dtstart=parse("19970902T090000"))),
[datetime(1998, 1, 6, 9, 0),
datetime(1998, 1, 29, 9, 0),
datetime(1998, 3, 3, 9, 0)])
def testYearlyByMonthAndNWeekDayLarge(self):
# This is interesting because the TH(-3) ends up before
# the TU(3).
self.assertEqual(list(rrule(YEARLY,
count=3,
bymonth=(1, 3),
byweekday=(TU(3), TH(-3)),
dtstart=parse("19970902T090000"))),
[datetime(1998, 1, 15, 9, 0),
datetime(1998, 1, 20, 9, 0),
datetime(1998, 3, 12, 9, 0)])
def testYearlyByMonthDayAndWeekDay(self):
self.assertEqual(list(rrule(YEARLY,
count=3,
bymonthday=(1, 3),
byweekday=(TU, TH),
dtstart=parse("19970902T090000"))),
[datetime(1998, 1, 1, 9, 0),
datetime(1998, 2, 3, 9, 0),
datetime(1998, 3, 3, 9, 0)])
def testYearlyByMonthAndMonthDayAndWeekDay(self):
self.assertEqual(list(rrule(YEARLY,
count=3,
bymonth=(1, 3),
bymonthday=(1, 3),
byweekday=(TU, TH),
dtstart=parse("19970902T090000"))),
[datetime(1998, 1, 1, 9, 0),
datetime(1998, 3, 3, 9, 0),
datetime(2001, 3, 1, 9, 0)])
def testYearlyByYearDay(self):
self.assertEqual(list(rrule(YEARLY,
count=4,
byyearday=(1, 100, 200, 365),
dtstart=parse("19970902T090000"))),
[datetime(1997, 12, 31, 9, 0),
datetime(1998, 1, 1, 9, 0),
datetime(1998, 4, 10, 9, 0),
datetime(1998, 7, 19, 9, 0)])
def testYearlyByYearDayNeg(self):
self.assertEqual(list(rrule(YEARLY,
count=4,
byyearday=(-365, -266, -166, -1),
dtstart=parse("19970902T090000"))),
[datetime(1997, 12, 31, 9, 0),
datetime(1998, 1, 1, 9, 0),
datetime(1998, 4, 10, 9, 0),
datetime(1998, 7, 19, 9, 0)])
def testYearlyByMonthAndYearDay(self):
self.assertEqual(list(rrule(YEARLY,
count=4,
bymonth=(4, 7),
byyearday=(1, 100, 200, 365),
dtstart=parse("19970902T090000"))),
[datetime(1998, 4, 10, 9, 0),
datetime(1998, 7, 19, 9, 0),
datetime(1999, 4, 10, 9, 0),
datetime(1999, 7, 19, 9, 0)])
def testYearlyByMonthAndYearDayNeg(self):
self.assertEqual(list(rrule(YEARLY,
count=4,
bymonth=(4, 7),
byyearday=(-365, -266, -166, -1),
dtstart=parse("19970902T090000"))),
[datetime(1998, 4, 10, 9, 0),
datetime(1998, 7, 19, 9, 0),
datetime(1999, 4, 10, 9, 0),
datetime(1999, 7, 19, 9, 0)])
def testYearlyByWeekNo(self):
self.assertEqual(list(rrule(YEARLY,
count=3,
byweekno=20,
dtstart=parse("19970902T090000"))),
[datetime(1998, 5, 11, 9, 0),
datetime(1998, 5, 12, 9, 0),
datetime(1998, 5, 13, 9, 0)])
def testYearlyByWeekNoAndWeekDay(self):
# That's a nice one. The first days of week number one
# may be in the last year.
self.assertEqual(list(rrule(YEARLY,
count=3,
byweekno=1,
byweekday=MO,
dtstart=parse("19970902T090000"))),
[datetime(1997, 12, 29, 9, 0),
datetime(1999, 1, 4, 9, 0),
datetime(2000, 1, 3, 9, 0)])
def testYearlyByWeekNoAndWeekDayLarge(self):
# Another nice test. The last days of week number 52/53
# may be in the next year.
self.assertEqual(list(rrule(YEARLY,
count=3,
byweekno=52,
byweekday=SU,
dtstart=parse("19970902T090000"))),
[datetime(1997, 12, 28, 9, 0),
datetime(1998, 12, 27, 9, 0),
datetime(2000, 1, 2, 9, 0)])
def testYearlyByWeekNoAndWeekDayLast(self):
self.assertEqual(list(rrule(YEARLY,
count=3,
byweekno=-1,
byweekday=SU,
dtstart=parse("19970902T090000"))),
[datetime(1997, 12, 28, 9, 0),
datetime(1999, 1, 3, 9, 0),
datetime(2000, 1, 2, 9, 0)])
def testYearlyByEaster(self):
self.assertEqual(list(rrule(YEARLY,
count=3,
byeaster=0,
dtstart=parse("19970902T090000"))),
[datetime(1998, 4, 12, 9, 0),
datetime(1999, 4, 4, 9, 0),
datetime(2000, 4, 23, 9, 0)])
def testYearlyByEasterPos(self):
self.assertEqual(list(rrule(YEARLY,
count=3,
byeaster=1,
dtstart=parse("19970902T090000"))),
[datetime(1998, 4, 13, 9, 0),
datetime(1999, 4, 5, 9, 0),
datetime(2000, 4, 24, 9, 0)])
def testYearlyByEasterNeg(self):
self.assertEqual(list(rrule(YEARLY,
count=3,
byeaster=-1,
dtstart=parse("19970902T090000"))),
[datetime(1998, 4, 11, 9, 0),
datetime(1999, 4, 3, 9, 0),
datetime(2000, 4, 22, 9, 0)])
def testYearlyByWeekNoAndWeekDay53(self):
self.assertEqual(list(rrule(YEARLY,
count=3,
byweekno=53,
byweekday=MO,
dtstart=parse("19970902T090000"))),
[datetime(1998, 12, 28, 9, 0),
datetime(2004, 12, 27, 9, 0),
datetime(2009, 12, 28, 9, 0)])
def testYearlyByHour(self):
self.assertEqual(list(rrule(YEARLY,
count=3,
byhour=(6, 18),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 18, 0),
datetime(1998, 9, 2, 6, 0),
datetime(1998, 9, 2, 18, 0)])
def testYearlyByMinute(self):
self.assertEqual(list(rrule(YEARLY,
count=3,
byminute=(6, 18),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 9, 6),
datetime(1997, 9, 2, 9, 18),
datetime(1998, 9, 2, 9, 6)])
def testYearlyBySecond(self):
self.assertEqual(list(rrule(YEARLY,
count=3,
bysecond=(6, 18),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 9, 0, 6),
datetime(1997, 9, 2, 9, 0, 18),
datetime(1998, 9, 2, 9, 0, 6)])
def testYearlyByHourAndMinute(self):
self.assertEqual(list(rrule(YEARLY,
count=3,
byhour=(6, 18),
byminute=(6, 18),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 18, 6),
datetime(1997, 9, 2, 18, 18),
datetime(1998, 9, 2, 6, 6)])
def testYearlyByHourAndSecond(self):
self.assertEqual(list(rrule(YEARLY,
count=3,
byhour=(6, 18),
bysecond=(6, 18),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 18, 0, 6),
datetime(1997, 9, 2, 18, 0, 18),
datetime(1998, 9, 2, 6, 0, 6)])
def testYearlyByMinuteAndSecond(self):
self.assertEqual(list(rrule(YEARLY,
count=3,
byminute=(6, 18),
bysecond=(6, 18),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 9, 6, 6),
datetime(1997, 9, 2, 9, 6, 18),
datetime(1997, 9, 2, 9, 18, 6)])
def testYearlyByHourAndMinuteAndSecond(self):
self.assertEqual(list(rrule(YEARLY,
count=3,
byhour=(6, 18),
byminute=(6, 18),
bysecond=(6, 18),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 18, 6, 6),
datetime(1997, 9, 2, 18, 6, 18),
datetime(1997, 9, 2, 18, 18, 6)])
def testYearlyBySetPos(self):
self.assertEqual(list(rrule(YEARLY,
count=3,
bymonthday=15,
byhour=(6, 18),
bysetpos=(3, -3),
dtstart=parse("19970902T090000"))),
[datetime(1997, 11, 15, 18, 0),
datetime(1998, 2, 15, 6, 0),
datetime(1998, 11, 15, 18, 0)])
def testMonthly(self):
self.assertEqual(list(rrule(MONTHLY,
count=3,
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 9, 0),
datetime(1997, 10, 2, 9, 0),
datetime(1997, 11, 2, 9, 0)])
def testMonthlyInterval(self):
self.assertEqual(list(rrule(MONTHLY,
count=3,
interval=2,
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 9, 0),
datetime(1997, 11, 2, 9, 0),
datetime(1998, 1, 2, 9, 0)])
def testMonthlyIntervalLarge(self):
self.assertEqual(list(rrule(MONTHLY,
count=3,
interval=18,
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 9, 0),
datetime(1999, 3, 2, 9, 0),
datetime(2000, 9, 2, 9, 0)])
def testMonthlyByMonth(self):
self.assertEqual(list(rrule(MONTHLY,
count=3,
bymonth=(1, 3),
dtstart=parse("19970902T090000"))),
[datetime(1998, 1, 2, 9, 0),
datetime(1998, 3, 2, 9, 0),
datetime(1999, 1, 2, 9, 0)])
def testMonthlyByMonthDay(self):
self.assertEqual(list(rrule(MONTHLY,
count=3,
bymonthday=(1, 3),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 3, 9, 0),
datetime(1997, 10, 1, 9, 0),
datetime(1997, 10, 3, 9, 0)])
def testMonthlyByMonthAndMonthDay(self):
self.assertEqual(list(rrule(MONTHLY,
count=3,
bymonth=(1, 3),
bymonthday=(5, 7),
dtstart=parse("19970902T090000"))),
[datetime(1998, 1, 5, 9, 0),
datetime(1998, 1, 7, 9, 0),
datetime(1998, 3, 5, 9, 0)])
def testMonthlyByWeekDay(self):
self.assertEqual(list(rrule(MONTHLY,
count=3,
byweekday=(TU, TH),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 9, 0),
datetime(1997, 9, 4, 9, 0),
datetime(1997, 9, 9, 9, 0)])
def testMonthlyByNWeekDay(self):
self.assertEqual(list(rrule(MONTHLY,
count=3,
byweekday=(TU(1), TH(-1)),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 9, 0),
datetime(1997, 9, 25, 9, 0),
datetime(1997, 10, 7, 9, 0)])
def testMonthlyByNWeekDayLarge(self):
self.assertEqual(list(rrule(MONTHLY,
count=3,
byweekday=(TU(3), TH(-3)),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 11, 9, 0),
datetime(1997, 9, 16, 9, 0),
datetime(1997, 10, 16, 9, 0)])
def testMonthlyByMonthAndWeekDay(self):
self.assertEqual(list(rrule(MONTHLY,
count=3,
bymonth=(1, 3),
byweekday=(TU, TH),
dtstart=parse("19970902T090000"))),
[datetime(1998, 1, 1, 9, 0),
datetime(1998, 1, 6, 9, 0),
datetime(1998, 1, 8, 9, 0)])
def testMonthlyByMonthAndNWeekDay(self):
self.assertEqual(list(rrule(MONTHLY,
count=3,
bymonth=(1, 3),
byweekday=(TU(1), TH(-1)),
dtstart=parse("19970902T090000"))),
[datetime(1998, 1, 6, 9, 0),
datetime(1998, 1, 29, 9, 0),
datetime(1998, 3, 3, 9, 0)])
def testMonthlyByMonthAndNWeekDayLarge(self):
self.assertEqual(list(rrule(MONTHLY,
count=3,
bymonth=(1, 3),
byweekday=(TU(3), TH(-3)),
dtstart=parse("19970902T090000"))),
[datetime(1998, 1, 15, 9, 0),
datetime(1998, 1, 20, 9, 0),
datetime(1998, 3, 12, 9, 0)])
def testMonthlyByMonthDayAndWeekDay(self):
self.assertEqual(list(rrule(MONTHLY,
count=3,
bymonthday=(1, 3),
byweekday=(TU, TH),
dtstart=parse("19970902T090000"))),
[datetime(1998, 1, 1, 9, 0),
datetime(1998, 2, 3, 9, 0),
datetime(1998, 3, 3, 9, 0)])
def testMonthlyByMonthAndMonthDayAndWeekDay(self):
self.assertEqual(list(rrule(MONTHLY,
count=3,
bymonth=(1, 3),
bymonthday=(1, 3),
byweekday=(TU, TH),
dtstart=parse("19970902T090000"))),
[datetime(1998, 1, 1, 9, 0),
datetime(1998, 3, 3, 9, 0),
datetime(2001, 3, 1, 9, 0)])
def testMonthlyByYearDay(self):
self.assertEqual(list(rrule(MONTHLY,
count=4,
byyearday=(1, 100, 200, 365),
dtstart=parse("19970902T090000"))),
[datetime(1997, 12, 31, 9, 0),
datetime(1998, 1, 1, 9, 0),
datetime(1998, 4, 10, 9, 0),
datetime(1998, 7, 19, 9, 0)])
def testMonthlyByYearDayNeg(self):
self.assertEqual(list(rrule(MONTHLY,
count=4,
byyearday=(-365, -266, -166, -1),
dtstart=parse("19970902T090000"))),
[datetime(1997, 12, 31, 9, 0),
datetime(1998, 1, 1, 9, 0),
datetime(1998, 4, 10, 9, 0),
datetime(1998, 7, 19, 9, 0)])
def testMonthlyByMonthAndYearDay(self):
self.assertEqual(list(rrule(MONTHLY,
count=4,
bymonth=(4, 7),
byyearday=(1, 100, 200, 365),
dtstart=parse("19970902T090000"))),
[datetime(1998, 4, 10, 9, 0),
datetime(1998, 7, 19, 9, 0),
datetime(1999, 4, 10, 9, 0),
datetime(1999, 7, 19, 9, 0)])
def testMonthlyByMonthAndYearDayNeg(self):
self.assertEqual(list(rrule(MONTHLY,
count=4,
bymonth=(4, 7),
byyearday=(-365, -266, -166, -1),
dtstart=parse("19970902T090000"))),
[datetime(1998, 4, 10, 9, 0),
datetime(1998, 7, 19, 9, 0),
datetime(1999, 4, 10, 9, 0),
datetime(1999, 7, 19, 9, 0)])
def testMonthlyByWeekNo(self):
self.assertEqual(list(rrule(MONTHLY,
count=3,
byweekno=20,
dtstart=parse("19970902T090000"))),
[datetime(1998, 5, 11, 9, 0),
datetime(1998, 5, 12, 9, 0),
datetime(1998, 5, 13, 9, 0)])
def testMonthlyByWeekNoAndWeekDay(self):
# That's a nice one. The first days of week number one
# may be in the last year.
self.assertEqual(list(rrule(MONTHLY,
count=3,
byweekno=1,
byweekday=MO,
dtstart=parse("19970902T090000"))),
[datetime(1997, 12, 29, 9, 0),
datetime(1999, 1, 4, 9, 0),
datetime(2000, 1, 3, 9, 0)])
def testMonthlyByWeekNoAndWeekDayLarge(self):
# Another nice test. The last days of week number 52/53
# may be in the next year.
self.assertEqual(list(rrule(MONTHLY,
count=3,
byweekno=52,
byweekday=SU,
dtstart=parse("19970902T090000"))),
[datetime(1997, 12, 28, 9, 0),
datetime(1998, 12, 27, 9, 0),
datetime(2000, 1, 2, 9, 0)])
def testMonthlyByWeekNoAndWeekDayLast(self):
self.assertEqual(list(rrule(MONTHLY,
count=3,
byweekno=-1,
byweekday=SU,
dtstart=parse("19970902T090000"))),
[datetime(1997, 12, 28, 9, 0),
datetime(1999, 1, 3, 9, 0),
datetime(2000, 1, 2, 9, 0)])
def testMonthlyByWeekNoAndWeekDay53(self):
self.assertEqual(list(rrule(MONTHLY,
count=3,
byweekno=53,
byweekday=MO,
dtstart=parse("19970902T090000"))),
[datetime(1998, 12, 28, 9, 0),
datetime(2004, 12, 27, 9, 0),
datetime(2009, 12, 28, 9, 0)])
def testMonthlyByEaster(self):
self.assertEqual(list(rrule(MONTHLY,
count=3,
byeaster=0,
dtstart=parse("19970902T090000"))),
[datetime(1998, 4, 12, 9, 0),
datetime(1999, 4, 4, 9, 0),
datetime(2000, 4, 23, 9, 0)])
def testMonthlyByEasterPos(self):
self.assertEqual(list(rrule(MONTHLY,
count=3,
byeaster=1,
dtstart=parse("19970902T090000"))),
[datetime(1998, 4, 13, 9, 0),
datetime(1999, 4, 5, 9, 0),
datetime(2000, 4, 24, 9, 0)])
def testMonthlyByEasterNeg(self):
self.assertEqual(list(rrule(MONTHLY,
count=3,
byeaster=-1,
dtstart=parse("19970902T090000"))),
[datetime(1998, 4, 11, 9, 0),
datetime(1999, 4, 3, 9, 0),
datetime(2000, 4, 22, 9, 0)])
def testMonthlyByHour(self):
self.assertEqual(list(rrule(MONTHLY,
count=3,
byhour=(6, 18),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 18, 0),
datetime(1997, 10, 2, 6, 0),
datetime(1997, 10, 2, 18, 0)])
def testMonthlyByMinute(self):
self.assertEqual(list(rrule(MONTHLY,
count=3,
byminute=(6, 18),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 9, 6),
datetime(1997, 9, 2, 9, 18),
datetime(1997, 10, 2, 9, 6)])
def testMonthlyBySecond(self):
self.assertEqual(list(rrule(MONTHLY,
count=3,
bysecond=(6, 18),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 9, 0, 6),
datetime(1997, 9, 2, 9, 0, 18),
datetime(1997, 10, 2, 9, 0, 6)])
def testMonthlyByHourAndMinute(self):
self.assertEqual(list(rrule(MONTHLY,
count=3,
byhour=(6, 18),
byminute=(6, 18),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 18, 6),
datetime(1997, 9, 2, 18, 18),
datetime(1997, 10, 2, 6, 6)])
def testMonthlyByHourAndSecond(self):
self.assertEqual(list(rrule(MONTHLY,
count=3,
byhour=(6, 18),
bysecond=(6, 18),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 18, 0, 6),
datetime(1997, 9, 2, 18, 0, 18),
datetime(1997, 10, 2, 6, 0, 6)])
def testMonthlyByMinuteAndSecond(self):
self.assertEqual(list(rrule(MONTHLY,
count=3,
byminute=(6, 18),
bysecond=(6, 18),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 9, 6, 6),
datetime(1997, 9, 2, 9, 6, 18),
datetime(1997, 9, 2, 9, 18, 6)])
def testMonthlyByHourAndMinuteAndSecond(self):
self.assertEqual(list(rrule(MONTHLY,
count=3,
byhour=(6, 18),
byminute=(6, 18),
bysecond=(6, 18),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 18, 6, 6),
datetime(1997, 9, 2, 18, 6, 18),
datetime(1997, 9, 2, 18, 18, 6)])
def testMonthlyBySetPos(self):
self.assertEqual(list(rrule(MONTHLY,
count=3,
bymonthday=(13, 17),
byhour=(6, 18),
bysetpos=(3, -3),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 13, 18, 0),
datetime(1997, 9, 17, 6, 0),
datetime(1997, 10, 13, 18, 0)])
def testWeekly(self):
self.assertEqual(list(rrule(WEEKLY,
count=3,
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 9, 0),
datetime(1997, 9, 9, 9, 0),
datetime(1997, 9, 16, 9, 0)])
def testWeeklyInterval(self):
self.assertEqual(list(rrule(WEEKLY,
count=3,
interval=2,
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 9, 0),
datetime(1997, 9, 16, 9, 0),
datetime(1997, 9, 30, 9, 0)])
def testWeeklyIntervalLarge(self):
self.assertEqual(list(rrule(WEEKLY,
count=3,
interval=20,
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 9, 0),
datetime(1998, 1, 20, 9, 0),
datetime(1998, 6, 9, 9, 0)])
def testWeeklyByMonth(self):
self.assertEqual(list(rrule(WEEKLY,
count=3,
bymonth=(1, 3),
dtstart=parse("19970902T090000"))),
[datetime(1998, 1, 6, 9, 0),
datetime(1998, 1, 13, 9, 0),
datetime(1998, 1, 20, 9, 0)])
def testWeeklyByMonthDay(self):
self.assertEqual(list(rrule(WEEKLY,
count=3,
bymonthday=(1, 3),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 3, 9, 0),
datetime(1997, 10, 1, 9, 0),
datetime(1997, 10, 3, 9, 0)])
def testWeeklyByMonthAndMonthDay(self):
self.assertEqual(list(rrule(WEEKLY,
count=3,
bymonth=(1, 3),
bymonthday=(5, 7),
dtstart=parse("19970902T090000"))),
[datetime(1998, 1, 5, 9, 0),
datetime(1998, 1, 7, 9, 0),
datetime(1998, 3, 5, 9, 0)])
def testWeeklyByWeekDay(self):
self.assertEqual(list(rrule(WEEKLY,
count=3,
byweekday=(TU, TH),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 9, 0),
datetime(1997, 9, 4, 9, 0),
datetime(1997, 9, 9, 9, 0)])
def testWeeklyByNWeekDay(self):
self.assertEqual(list(rrule(WEEKLY,
count=3,
byweekday=(TU(1), TH(-1)),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 9, 0),
datetime(1997, 9, 4, 9, 0),
datetime(1997, 9, 9, 9, 0)])
def testWeeklyByMonthAndWeekDay(self):
# This test is interesting, because it crosses the year
# boundary in a weekly period to find day '1' as a
# valid recurrence.
self.assertEqual(list(rrule(WEEKLY,
count=3,
bymonth=(1, 3),
byweekday=(TU, TH),
dtstart=parse("19970902T090000"))),
[datetime(1998, 1, 1, 9, 0),
datetime(1998, 1, 6, 9, 0),
datetime(1998, 1, 8, 9, 0)])
def testWeeklyByMonthAndNWeekDay(self):
self.assertEqual(list(rrule(WEEKLY,
count=3,
bymonth=(1, 3),
byweekday=(TU(1), TH(-1)),
dtstart=parse("19970902T090000"))),
[datetime(1998, 1, 1, 9, 0),
datetime(1998, 1, 6, 9, 0),
datetime(1998, 1, 8, 9, 0)])
def testWeeklyByMonthDayAndWeekDay(self):
self.assertEqual(list(rrule(WEEKLY,
count=3,
bymonthday=(1, 3),
byweekday=(TU, TH),
dtstart=parse("19970902T090000"))),
[datetime(1998, 1, 1, 9, 0),
datetime(1998, 2, 3, 9, 0),
datetime(1998, 3, 3, 9, 0)])
def testWeeklyByMonthAndMonthDayAndWeekDay(self):
self.assertEqual(list(rrule(WEEKLY,
count=3,
bymonth=(1, 3),
bymonthday=(1, 3),
byweekday=(TU, TH),
dtstart=parse("19970902T090000"))),
[datetime(1998, 1, 1, 9, 0),
datetime(1998, 3, 3, 9, 0),
datetime(2001, 3, 1, 9, 0)])
def testWeeklyByYearDay(self):
self.assertEqual(list(rrule(WEEKLY,
count=4,
byyearday=(1, 100, 200, 365),
dtstart=parse("19970902T090000"))),
[datetime(1997, 12, 31, 9, 0),
datetime(1998, 1, 1, 9, 0),
datetime(1998, 4, 10, 9, 0),
datetime(1998, 7, 19, 9, 0)])
def testWeeklyByYearDayNeg(self):
self.assertEqual(list(rrule(WEEKLY,
count=4,
byyearday=(-365, -266, -166, -1),
dtstart=parse("19970902T090000"))),
[datetime(1997, 12, 31, 9, 0),
datetime(1998, 1, 1, 9, 0),
datetime(1998, 4, 10, 9, 0),
datetime(1998, 7, 19, 9, 0)])
def testWeeklyByMonthAndYearDay(self):
self.assertEqual(list(rrule(WEEKLY,
count=4,
bymonth=(1, 7),
byyearday=(1, 100, 200, 365),
dtstart=parse("19970902T090000"))),
[datetime(1998, 1, 1, 9, 0),
datetime(1998, 7, 19, 9, 0),
datetime(1999, 1, 1, 9, 0),
datetime(1999, 7, 19, 9, 0)])
def testWeeklyByMonthAndYearDayNeg(self):
self.assertEqual(list(rrule(WEEKLY,
count=4,
bymonth=(1, 7),
byyearday=(-365, -266, -166, -1),
dtstart=parse("19970902T090000"))),
[datetime(1998, 1, 1, 9, 0),
datetime(1998, 7, 19, 9, 0),
datetime(1999, 1, 1, 9, 0),
datetime(1999, 7, 19, 9, 0)])
def testWeeklyByWeekNo(self):
self.assertEqual(list(rrule(WEEKLY,
count=3,
byweekno=20,
dtstart=parse("19970902T090000"))),
[datetime(1998, 5, 11, 9, 0),
datetime(1998, 5, 12, 9, 0),
datetime(1998, 5, 13, 9, 0)])
def testWeeklyByWeekNoAndWeekDay(self):
# That's a nice one. The first days of week number one
# may be in the last year.
self.assertEqual(list(rrule(WEEKLY,
count=3,
byweekno=1,
byweekday=MO,
dtstart=parse("19970902T090000"))),
[datetime(1997, 12, 29, 9, 0),
datetime(1999, 1, 4, 9, 0),
datetime(2000, 1, 3, 9, 0)])
def testWeeklyByWeekNoAndWeekDayLarge(self):
# Another nice test. The last days of week number 52/53
# may be in the next year.
self.assertEqual(list(rrule(WEEKLY,
count=3,
byweekno=52,
byweekday=SU,
dtstart=parse("19970902T090000"))),
[datetime(1997, 12, 28, 9, 0),
datetime(1998, 12, 27, 9, 0),
datetime(2000, 1, 2, 9, 0)])
def testWeeklyByWeekNoAndWeekDayLast(self):
self.assertEqual(list(rrule(WEEKLY,
count=3,
byweekno=-1,
byweekday=SU,
dtstart=parse("19970902T090000"))),
[datetime(1997, 12, 28, 9, 0),
datetime(1999, 1, 3, 9, 0),
datetime(2000, 1, 2, 9, 0)])
def testWeeklyByWeekNoAndWeekDay53(self):
self.assertEqual(list(rrule(WEEKLY,
count=3,
byweekno=53,
byweekday=MO,
dtstart=parse("19970902T090000"))),
[datetime(1998, 12, 28, 9, 0),
datetime(2004, 12, 27, 9, 0),
datetime(2009, 12, 28, 9, 0)])
def testWeeklyByEaster(self):
self.assertEqual(list(rrule(WEEKLY,
count=3,
byeaster=0,
dtstart=parse("19970902T090000"))),
[datetime(1998, 4, 12, 9, 0),
datetime(1999, 4, 4, 9, 0),
datetime(2000, 4, 23, 9, 0)])
def testWeeklyByEasterPos(self):
self.assertEqual(list(rrule(WEEKLY,
count=3,
byeaster=1,
dtstart=parse("19970902T090000"))),
[datetime(1998, 4, 13, 9, 0),
datetime(1999, 4, 5, 9, 0),
datetime(2000, 4, 24, 9, 0)])
def testWeeklyByEasterNeg(self):
self.assertEqual(list(rrule(WEEKLY,
count=3,
byeaster=-1,
dtstart=parse("19970902T090000"))),
[datetime(1998, 4, 11, 9, 0),
datetime(1999, 4, 3, 9, 0),
datetime(2000, 4, 22, 9, 0)])
def testWeeklyByHour(self):
self.assertEqual(list(rrule(WEEKLY,
count=3,
byhour=(6, 18),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 18, 0),
datetime(1997, 9, 9, 6, 0),
datetime(1997, 9, 9, 18, 0)])
def testWeeklyByMinute(self):
self.assertEqual(list(rrule(WEEKLY,
count=3,
byminute=(6, 18),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 9, 6),
datetime(1997, 9, 2, 9, 18),
datetime(1997, 9, 9, 9, 6)])
def testWeeklyBySecond(self):
self.assertEqual(list(rrule(WEEKLY,
count=3,
bysecond=(6, 18),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 9, 0, 6),
datetime(1997, 9, 2, 9, 0, 18),
datetime(1997, 9, 9, 9, 0, 6)])
def testWeeklyByHourAndMinute(self):
self.assertEqual(list(rrule(WEEKLY,
count=3,
byhour=(6, 18),
byminute=(6, 18),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 18, 6),
datetime(1997, 9, 2, 18, 18),
datetime(1997, 9, 9, 6, 6)])
def testWeeklyByHourAndSecond(self):
self.assertEqual(list(rrule(WEEKLY,
count=3,
byhour=(6, 18),
bysecond=(6, 18),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 18, 0, 6),
datetime(1997, 9, 2, 18, 0, 18),
datetime(1997, 9, 9, 6, 0, 6)])
def testWeeklyByMinuteAndSecond(self):
self.assertEqual(list(rrule(WEEKLY,
count=3,
byminute=(6, 18),
bysecond=(6, 18),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 9, 6, 6),
datetime(1997, 9, 2, 9, 6, 18),
datetime(1997, 9, 2, 9, 18, 6)])
def testWeeklyByHourAndMinuteAndSecond(self):
self.assertEqual(list(rrule(WEEKLY,
count=3,
byhour=(6, 18),
byminute=(6, 18),
bysecond=(6, 18),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 18, 6, 6),
datetime(1997, 9, 2, 18, 6, 18),
datetime(1997, 9, 2, 18, 18, 6)])
def testWeeklyBySetPos(self):
self.assertEqual(list(rrule(WEEKLY,
count=3,
byweekday=(TU, TH),
byhour=(6, 18),
bysetpos=(3, -3),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 18, 0),
datetime(1997, 9, 4, 6, 0),
datetime(1997, 9, 9, 18, 0)])
def testDaily(self):
self.assertEqual(list(rrule(DAILY,
count=3,
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 9, 0),
datetime(1997, 9, 3, 9, 0),
datetime(1997, 9, 4, 9, 0)])
def testDailyInterval(self):
self.assertEqual(list(rrule(DAILY,
count=3,
interval=2,
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 9, 0),
datetime(1997, 9, 4, 9, 0),
datetime(1997, 9, 6, 9, 0)])
def testDailyIntervalLarge(self):
self.assertEqual(list(rrule(DAILY,
count=3,
interval=92,
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 9, 0),
datetime(1997, 12, 3, 9, 0),
datetime(1998, 3, 5, 9, 0)])
def testDailyByMonth(self):
self.assertEqual(list(rrule(DAILY,
count=3,
bymonth=(1, 3),
dtstart=parse("19970902T090000"))),
[datetime(1998, 1, 1, 9, 0),
datetime(1998, 1, 2, 9, 0),
datetime(1998, 1, 3, 9, 0)])
def testDailyByMonthDay(self):
self.assertEqual(list(rrule(DAILY,
count=3,
bymonthday=(1, 3),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 3, 9, 0),
datetime(1997, 10, 1, 9, 0),
datetime(1997, 10, 3, 9, 0)])
def testDailyByMonthAndMonthDay(self):
self.assertEqual(list(rrule(DAILY,
count=3,
bymonth=(1, 3),
bymonthday=(5, 7),
dtstart=parse("19970902T090000"))),
[datetime(1998, 1, 5, 9, 0),
datetime(1998, 1, 7, 9, 0),
datetime(1998, 3, 5, 9, 0)])
def testDailyByWeekDay(self):
self.assertEqual(list(rrule(DAILY,
count=3,
byweekday=(TU, TH),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 9, 0),
datetime(1997, 9, 4, 9, 0),
datetime(1997, 9, 9, 9, 0)])
def testDailyByNWeekDay(self):
self.assertEqual(list(rrule(DAILY,
count=3,
byweekday=(TU(1), TH(-1)),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 9, 0),
datetime(1997, 9, 4, 9, 0),
datetime(1997, 9, 9, 9, 0)])
def testDailyByMonthAndWeekDay(self):
self.assertEqual(list(rrule(DAILY,
count=3,
bymonth=(1, 3),
byweekday=(TU, TH),
dtstart=parse("19970902T090000"))),
[datetime(1998, 1, 1, 9, 0),
datetime(1998, 1, 6, 9, 0),
datetime(1998, 1, 8, 9, 0)])
def testDailyByMonthAndNWeekDay(self):
self.assertEqual(list(rrule(DAILY,
count=3,
bymonth=(1, 3),
byweekday=(TU(1), TH(-1)),
dtstart=parse("19970902T090000"))),
[datetime(1998, 1, 1, 9, 0),
datetime(1998, 1, 6, 9, 0),
datetime(1998, 1, 8, 9, 0)])
def testDailyByMonthDayAndWeekDay(self):
self.assertEqual(list(rrule(DAILY,
count=3,
bymonthday=(1, 3),
byweekday=(TU, TH),
dtstart=parse("19970902T090000"))),
[datetime(1998, 1, 1, 9, 0),
datetime(1998, 2, 3, 9, 0),
datetime(1998, 3, 3, 9, 0)])
def testDailyByMonthAndMonthDayAndWeekDay(self):
self.assertEqual(list(rrule(DAILY,
count=3,
bymonth=(1, 3),
bymonthday=(1, 3),
byweekday=(TU, TH),
dtstart=parse("19970902T090000"))),
[datetime(1998, 1, 1, 9, 0),
datetime(1998, 3, 3, 9, 0),
datetime(2001, 3, 1, 9, 0)])
def testDailyByYearDay(self):
self.assertEqual(list(rrule(DAILY,
count=4,
byyearday=(1, 100, 200, 365),
dtstart=parse("19970902T090000"))),
[datetime(1997, 12, 31, 9, 0),
datetime(1998, 1, 1, 9, 0),
datetime(1998, 4, 10, 9, 0),
datetime(1998, 7, 19, 9, 0)])
def testDailyByYearDayNeg(self):
self.assertEqual(list(rrule(DAILY,
count=4,
byyearday=(-365, -266, -166, -1),
dtstart=parse("19970902T090000"))),
[datetime(1997, 12, 31, 9, 0),
datetime(1998, 1, 1, 9, 0),
datetime(1998, 4, 10, 9, 0),
datetime(1998, 7, 19, 9, 0)])
def testDailyByMonthAndYearDay(self):
self.assertEqual(list(rrule(DAILY,
count=4,
bymonth=(1, 7),
byyearday=(1, 100, 200, 365),
dtstart=parse("19970902T090000"))),
[datetime(1998, 1, 1, 9, 0),
datetime(1998, 7, 19, 9, 0),
datetime(1999, 1, 1, 9, 0),
datetime(1999, 7, 19, 9, 0)])
def testDailyByMonthAndYearDayNeg(self):
self.assertEqual(list(rrule(DAILY,
count=4,
bymonth=(1, 7),
byyearday=(-365, -266, -166, -1),
dtstart=parse("19970902T090000"))),
[datetime(1998, 1, 1, 9, 0),
datetime(1998, 7, 19, 9, 0),
datetime(1999, 1, 1, 9, 0),
datetime(1999, 7, 19, 9, 0)])
def testDailyByWeekNo(self):
self.assertEqual(list(rrule(DAILY,
count=3,
byweekno=20,
dtstart=parse("19970902T090000"))),
[datetime(1998, 5, 11, 9, 0),
datetime(1998, 5, 12, 9, 0),
datetime(1998, 5, 13, 9, 0)])
def testDailyByWeekNoAndWeekDay(self):
# That's a nice one. The first days of week number one
# may be in the last year.
self.assertEqual(list(rrule(DAILY,
count=3,
byweekno=1,
byweekday=MO,
dtstart=parse("19970902T090000"))),
[datetime(1997, 12, 29, 9, 0),
datetime(1999, 1, 4, 9, 0),
datetime(2000, 1, 3, 9, 0)])
def testDailyByWeekNoAndWeekDayLarge(self):
# Another nice test. The last days of week number 52/53
# may be in the next year.
self.assertEqual(list(rrule(DAILY,
count=3,
byweekno=52,
byweekday=SU,
dtstart=parse("19970902T090000"))),
[datetime(1997, 12, 28, 9, 0),
datetime(1998, 12, 27, 9, 0),
datetime(2000, 1, 2, 9, 0)])
def testDailyByWeekNoAndWeekDayLast(self):
self.assertEqual(list(rrule(DAILY,
count=3,
byweekno=-1,
byweekday=SU,
dtstart=parse("19970902T090000"))),
[datetime(1997, 12, 28, 9, 0),
datetime(1999, 1, 3, 9, 0),
datetime(2000, 1, 2, 9, 0)])
def testDailyByWeekNoAndWeekDay53(self):
self.assertEqual(list(rrule(DAILY,
count=3,
byweekno=53,
byweekday=MO,
dtstart=parse("19970902T090000"))),
[datetime(1998, 12, 28, 9, 0),
datetime(2004, 12, 27, 9, 0),
datetime(2009, 12, 28, 9, 0)])
def testDailyByEaster(self):
self.assertEqual(list(rrule(DAILY,
count=3,
byeaster=0,
dtstart=parse("19970902T090000"))),
[datetime(1998, 4, 12, 9, 0),
datetime(1999, 4, 4, 9, 0),
datetime(2000, 4, 23, 9, 0)])
def testDailyByEasterPos(self):
self.assertEqual(list(rrule(DAILY,
count=3,
byeaster=1,
dtstart=parse("19970902T090000"))),
[datetime(1998, 4, 13, 9, 0),
datetime(1999, 4, 5, 9, 0),
datetime(2000, 4, 24, 9, 0)])
def testDailyByEasterNeg(self):
self.assertEqual(list(rrule(DAILY,
count=3,
byeaster=-1,
dtstart=parse("19970902T090000"))),
[datetime(1998, 4, 11, 9, 0),
datetime(1999, 4, 3, 9, 0),
datetime(2000, 4, 22, 9, 0)])
def testDailyByHour(self):
self.assertEqual(list(rrule(DAILY,
count=3,
byhour=(6, 18),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 18, 0),
datetime(1997, 9, 3, 6, 0),
datetime(1997, 9, 3, 18, 0)])
def testDailyByMinute(self):
self.assertEqual(list(rrule(DAILY,
count=3,
byminute=(6, 18),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 9, 6),
datetime(1997, 9, 2, 9, 18),
datetime(1997, 9, 3, 9, 6)])
def testDailyBySecond(self):
self.assertEqual(list(rrule(DAILY,
count=3,
bysecond=(6, 18),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 9, 0, 6),
datetime(1997, 9, 2, 9, 0, 18),
datetime(1997, 9, 3, 9, 0, 6)])
def testDailyByHourAndMinute(self):
self.assertEqual(list(rrule(DAILY,
count=3,
byhour=(6, 18),
byminute=(6, 18),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 18, 6),
datetime(1997, 9, 2, 18, 18),
datetime(1997, 9, 3, 6, 6)])
def testDailyByHourAndSecond(self):
self.assertEqual(list(rrule(DAILY,
count=3,
byhour=(6, 18),
bysecond=(6, 18),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 18, 0, 6),
datetime(1997, 9, 2, 18, 0, 18),
datetime(1997, 9, 3, 6, 0, 6)])
def testDailyByMinuteAndSecond(self):
self.assertEqual(list(rrule(DAILY,
count=3,
byminute=(6, 18),
bysecond=(6, 18),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 9, 6, 6),
datetime(1997, 9, 2, 9, 6, 18),
datetime(1997, 9, 2, 9, 18, 6)])
def testDailyByHourAndMinuteAndSecond(self):
self.assertEqual(list(rrule(DAILY,
count=3,
byhour=(6, 18),
byminute=(6, 18),
bysecond=(6, 18),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 18, 6, 6),
datetime(1997, 9, 2, 18, 6, 18),
datetime(1997, 9, 2, 18, 18, 6)])
def testDailyBySetPos(self):
self.assertEqual(list(rrule(DAILY,
count=3,
byhour=(6, 18),
byminute=(15, 45),
bysetpos=(3, -3),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 18, 15),
datetime(1997, 9, 3, 6, 45),
datetime(1997, 9, 3, 18, 15)])
def testHourly(self):
self.assertEqual(list(rrule(HOURLY,
count=3,
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 9, 0),
datetime(1997, 9, 2, 10, 0),
datetime(1997, 9, 2, 11, 0)])
def testHourlyInterval(self):
self.assertEqual(list(rrule(HOURLY,
count=3,
interval=2,
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 9, 0),
datetime(1997, 9, 2, 11, 0),
datetime(1997, 9, 2, 13, 0)])
def testHourlyIntervalLarge(self):
self.assertEqual(list(rrule(HOURLY,
count=3,
interval=769,
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 9, 0),
datetime(1997, 10, 4, 10, 0),
datetime(1997, 11, 5, 11, 0)])
def testHourlyByMonth(self):
self.assertEqual(list(rrule(HOURLY,
count=3,
bymonth=(1, 3),
dtstart=parse("19970902T090000"))),
[datetime(1998, 1, 1, 0, 0),
datetime(1998, 1, 1, 1, 0),
datetime(1998, 1, 1, 2, 0)])
def testHourlyByMonthDay(self):
self.assertEqual(list(rrule(HOURLY,
count=3,
bymonthday=(1, 3),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 3, 0, 0),
datetime(1997, 9, 3, 1, 0),
datetime(1997, 9, 3, 2, 0)])
def testHourlyByMonthAndMonthDay(self):
self.assertEqual(list(rrule(HOURLY,
count=3,
bymonth=(1, 3),
bymonthday=(5, 7),
dtstart=parse("19970902T090000"))),
[datetime(1998, 1, 5, 0, 0),
datetime(1998, 1, 5, 1, 0),
datetime(1998, 1, 5, 2, 0)])
def testHourlyByWeekDay(self):
self.assertEqual(list(rrule(HOURLY,
count=3,
byweekday=(TU, TH),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 9, 0),
datetime(1997, 9, 2, 10, 0),
datetime(1997, 9, 2, 11, 0)])
def testHourlyByNWeekDay(self):
self.assertEqual(list(rrule(HOURLY,
count=3,
byweekday=(TU(1), TH(-1)),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 9, 0),
datetime(1997, 9, 2, 10, 0),
datetime(1997, 9, 2, 11, 0)])
def testHourlyByMonthAndWeekDay(self):
self.assertEqual(list(rrule(HOURLY,
count=3,
bymonth=(1, 3),
byweekday=(TU, TH),
dtstart=parse("19970902T090000"))),
[datetime(1998, 1, 1, 0, 0),
datetime(1998, 1, 1, 1, 0),
datetime(1998, 1, 1, 2, 0)])
def testHourlyByMonthAndNWeekDay(self):
self.assertEqual(list(rrule(HOURLY,
count=3,
bymonth=(1, 3),
byweekday=(TU(1), TH(-1)),
dtstart=parse("19970902T090000"))),
[datetime(1998, 1, 1, 0, 0),
datetime(1998, 1, 1, 1, 0),
datetime(1998, 1, 1, 2, 0)])
def testHourlyByMonthDayAndWeekDay(self):
self.assertEqual(list(rrule(HOURLY,
count=3,
bymonthday=(1, 3),
byweekday=(TU, TH),
dtstart=parse("19970902T090000"))),
[datetime(1998, 1, 1, 0, 0),
datetime(1998, 1, 1, 1, 0),
datetime(1998, 1, 1, 2, 0)])
def testHourlyByMonthAndMonthDayAndWeekDay(self):
self.assertEqual(list(rrule(HOURLY,
count=3,
bymonth=(1, 3),
bymonthday=(1, 3),
byweekday=(TU, TH),
dtstart=parse("19970902T090000"))),
[datetime(1998, 1, 1, 0, 0),
datetime(1998, 1, 1, 1, 0),
datetime(1998, 1, 1, 2, 0)])
def testHourlyByYearDay(self):
self.assertEqual(list(rrule(HOURLY,
count=4,
byyearday=(1, 100, 200, 365),
dtstart=parse("19970902T090000"))),
[datetime(1997, 12, 31, 0, 0),
datetime(1997, 12, 31, 1, 0),
datetime(1997, 12, 31, 2, 0),
datetime(1997, 12, 31, 3, 0)])
def testHourlyByYearDayNeg(self):
self.assertEqual(list(rrule(HOURLY,
count=4,
byyearday=(-365, -266, -166, -1),
dtstart=parse("19970902T090000"))),
[datetime(1997, 12, 31, 0, 0),
datetime(1997, 12, 31, 1, 0),
datetime(1997, 12, 31, 2, 0),
datetime(1997, 12, 31, 3, 0)])
def testHourlyByMonthAndYearDay(self):
self.assertEqual(list(rrule(HOURLY,
count=4,
bymonth=(4, 7),
byyearday=(1, 100, 200, 365),
dtstart=parse("19970902T090000"))),
[datetime(1998, 4, 10, 0, 0),
datetime(1998, 4, 10, 1, 0),
datetime(1998, 4, 10, 2, 0),
datetime(1998, 4, 10, 3, 0)])
def testHourlyByMonthAndYearDayNeg(self):
self.assertEqual(list(rrule(HOURLY,
count=4,
bymonth=(4, 7),
byyearday=(-365, -266, -166, -1),
dtstart=parse("19970902T090000"))),
[datetime(1998, 4, 10, 0, 0),
datetime(1998, 4, 10, 1, 0),
datetime(1998, 4, 10, 2, 0),
datetime(1998, 4, 10, 3, 0)])
def testHourlyByWeekNo(self):
self.assertEqual(list(rrule(HOURLY,
count=3,
byweekno=20,
dtstart=parse("19970902T090000"))),
[datetime(1998, 5, 11, 0, 0),
datetime(1998, 5, 11, 1, 0),
datetime(1998, 5, 11, 2, 0)])
def testHourlyByWeekNoAndWeekDay(self):
self.assertEqual(list(rrule(HOURLY,
count=3,
byweekno=1,
byweekday=MO,
dtstart=parse("19970902T090000"))),
[datetime(1997, 12, 29, 0, 0),
datetime(1997, 12, 29, 1, 0),
datetime(1997, 12, 29, 2, 0)])
def testHourlyByWeekNoAndWeekDayLarge(self):
self.assertEqual(list(rrule(HOURLY,
count=3,
byweekno=52,
byweekday=SU,
dtstart=parse("19970902T090000"))),
[datetime(1997, 12, 28, 0, 0),
datetime(1997, 12, 28, 1, 0),
datetime(1997, 12, 28, 2, 0)])
def testHourlyByWeekNoAndWeekDayLast(self):
self.assertEqual(list(rrule(HOURLY,
count=3,
byweekno=-1,
byweekday=SU,
dtstart=parse("19970902T090000"))),
[datetime(1997, 12, 28, 0, 0),
datetime(1997, 12, 28, 1, 0),
datetime(1997, 12, 28, 2, 0)])
def testHourlyByWeekNoAndWeekDay53(self):
self.assertEqual(list(rrule(HOURLY,
count=3,
byweekno=53,
byweekday=MO,
dtstart=parse("19970902T090000"))),
[datetime(1998, 12, 28, 0, 0),
datetime(1998, 12, 28, 1, 0),
datetime(1998, 12, 28, 2, 0)])
def testHourlyByEaster(self):
self.assertEqual(list(rrule(HOURLY,
count=3,
byeaster=0,
dtstart=parse("19970902T090000"))),
[datetime(1998, 4, 12, 0, 0),
datetime(1998, 4, 12, 1, 0),
datetime(1998, 4, 12, 2, 0)])
def testHourlyByEasterPos(self):
self.assertEqual(list(rrule(HOURLY,
count=3,
byeaster=1,
dtstart=parse("19970902T090000"))),
[datetime(1998, 4, 13, 0, 0),
datetime(1998, 4, 13, 1, 0),
datetime(1998, 4, 13, 2, 0)])
def testHourlyByEasterNeg(self):
self.assertEqual(list(rrule(HOURLY,
count=3,
byeaster=-1,
dtstart=parse("19970902T090000"))),
[datetime(1998, 4, 11, 0, 0),
datetime(1998, 4, 11, 1, 0),
datetime(1998, 4, 11, 2, 0)])
def testHourlyByHour(self):
self.assertEqual(list(rrule(HOURLY,
count=3,
byhour=(6, 18),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 18, 0),
datetime(1997, 9, 3, 6, 0),
datetime(1997, 9, 3, 18, 0)])
def testHourlyByMinute(self):
self.assertEqual(list(rrule(HOURLY,
count=3,
byminute=(6, 18),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 9, 6),
datetime(1997, 9, 2, 9, 18),
datetime(1997, 9, 2, 10, 6)])
def testHourlyBySecond(self):
self.assertEqual(list(rrule(HOURLY,
count=3,
bysecond=(6, 18),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 9, 0, 6),
datetime(1997, 9, 2, 9, 0, 18),
datetime(1997, 9, 2, 10, 0, 6)])
def testHourlyByHourAndMinute(self):
self.assertEqual(list(rrule(HOURLY,
count=3,
byhour=(6, 18),
byminute=(6, 18),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 18, 6),
datetime(1997, 9, 2, 18, 18),
datetime(1997, 9, 3, 6, 6)])
def testHourlyByHourAndSecond(self):
self.assertEqual(list(rrule(HOURLY,
count=3,
byhour=(6, 18),
bysecond=(6, 18),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 18, 0, 6),
datetime(1997, 9, 2, 18, 0, 18),
datetime(1997, 9, 3, 6, 0, 6)])
def testHourlyByMinuteAndSecond(self):
self.assertEqual(list(rrule(HOURLY,
count=3,
byminute=(6, 18),
bysecond=(6, 18),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 9, 6, 6),
datetime(1997, 9, 2, 9, 6, 18),
datetime(1997, 9, 2, 9, 18, 6)])
def testHourlyByHourAndMinuteAndSecond(self):
self.assertEqual(list(rrule(HOURLY,
count=3,
byhour=(6, 18),
byminute=(6, 18),
bysecond=(6, 18),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 18, 6, 6),
datetime(1997, 9, 2, 18, 6, 18),
datetime(1997, 9, 2, 18, 18, 6)])
def testHourlyBySetPos(self):
self.assertEqual(list(rrule(HOURLY,
count=3,
byminute=(15, 45),
bysecond=(15, 45),
bysetpos=(3, -3),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 9, 15, 45),
datetime(1997, 9, 2, 9, 45, 15),
datetime(1997, 9, 2, 10, 15, 45)])
def testMinutely(self):
self.assertEqual(list(rrule(MINUTELY,
count=3,
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 9, 0),
datetime(1997, 9, 2, 9, 1),
datetime(1997, 9, 2, 9, 2)])
def testMinutelyInterval(self):
self.assertEqual(list(rrule(MINUTELY,
count=3,
interval=2,
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 9, 0),
datetime(1997, 9, 2, 9, 2),
datetime(1997, 9, 2, 9, 4)])
def testMinutelyIntervalLarge(self):
self.assertEqual(list(rrule(MINUTELY,
count=3,
interval=1501,
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 9, 0),
datetime(1997, 9, 3, 10, 1),
datetime(1997, 9, 4, 11, 2)])
def testMinutelyByMonth(self):
self.assertEqual(list(rrule(MINUTELY,
count=3,
bymonth=(1, 3),
dtstart=parse("19970902T090000"))),
[datetime(1998, 1, 1, 0, 0),
datetime(1998, 1, 1, 0, 1),
datetime(1998, 1, 1, 0, 2)])
def testMinutelyByMonthDay(self):
self.assertEqual(list(rrule(MINUTELY,
count=3,
bymonthday=(1, 3),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 3, 0, 0),
datetime(1997, 9, 3, 0, 1),
datetime(1997, 9, 3, 0, 2)])
def testMinutelyByMonthAndMonthDay(self):
self.assertEqual(list(rrule(MINUTELY,
count=3,
bymonth=(1, 3),
bymonthday=(5, 7),
dtstart=parse("19970902T090000"))),
[datetime(1998, 1, 5, 0, 0),
datetime(1998, 1, 5, 0, 1),
datetime(1998, 1, 5, 0, 2)])
def testMinutelyByWeekDay(self):
self.assertEqual(list(rrule(MINUTELY,
count=3,
byweekday=(TU, TH),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 9, 0),
datetime(1997, 9, 2, 9, 1),
datetime(1997, 9, 2, 9, 2)])
def testMinutelyByNWeekDay(self):
self.assertEqual(list(rrule(MINUTELY,
count=3,
byweekday=(TU(1), TH(-1)),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 9, 0),
datetime(1997, 9, 2, 9, 1),
datetime(1997, 9, 2, 9, 2)])
def testMinutelyByMonthAndWeekDay(self):
self.assertEqual(list(rrule(MINUTELY,
count=3,
bymonth=(1, 3),
byweekday=(TU, TH),
dtstart=parse("19970902T090000"))),
[datetime(1998, 1, 1, 0, 0),
datetime(1998, 1, 1, 0, 1),
datetime(1998, 1, 1, 0, 2)])
def testMinutelyByMonthAndNWeekDay(self):
self.assertEqual(list(rrule(MINUTELY,
count=3,
bymonth=(1, 3),
byweekday=(TU(1), TH(-1)),
dtstart=parse("19970902T090000"))),
[datetime(1998, 1, 1, 0, 0),
datetime(1998, 1, 1, 0, 1),
datetime(1998, 1, 1, 0, 2)])
def testMinutelyByMonthDayAndWeekDay(self):
self.assertEqual(list(rrule(MINUTELY,
count=3,
bymonthday=(1, 3),
byweekday=(TU, TH),
dtstart=parse("19970902T090000"))),
[datetime(1998, 1, 1, 0, 0),
datetime(1998, 1, 1, 0, 1),
datetime(1998, 1, 1, 0, 2)])
def testMinutelyByMonthAndMonthDayAndWeekDay(self):
self.assertEqual(list(rrule(MINUTELY,
count=3,
bymonth=(1, 3),
bymonthday=(1, 3),
byweekday=(TU, TH),
dtstart=parse("19970902T090000"))),
[datetime(1998, 1, 1, 0, 0),
datetime(1998, 1, 1, 0, 1),
datetime(1998, 1, 1, 0, 2)])
def testMinutelyByYearDay(self):
self.assertEqual(list(rrule(MINUTELY,
count=4,
byyearday=(1, 100, 200, 365),
dtstart=parse("19970902T090000"))),
[datetime(1997, 12, 31, 0, 0),
datetime(1997, 12, 31, 0, 1),
datetime(1997, 12, 31, 0, 2),
datetime(1997, 12, 31, 0, 3)])
def testMinutelyByYearDayNeg(self):
self.assertEqual(list(rrule(MINUTELY,
count=4,
byyearday=(-365, -266, -166, -1),
dtstart=parse("19970902T090000"))),
[datetime(1997, 12, 31, 0, 0),
datetime(1997, 12, 31, 0, 1),
datetime(1997, 12, 31, 0, 2),
datetime(1997, 12, 31, 0, 3)])
def testMinutelyByMonthAndYearDay(self):
self.assertEqual(list(rrule(MINUTELY,
count=4,
bymonth=(4, 7),
byyearday=(1, 100, 200, 365),
dtstart=parse("19970902T090000"))),
[datetime(1998, 4, 10, 0, 0),
datetime(1998, 4, 10, 0, 1),
datetime(1998, 4, 10, 0, 2),
datetime(1998, 4, 10, 0, 3)])
def testMinutelyByMonthAndYearDayNeg(self):
self.assertEqual(list(rrule(MINUTELY,
count=4,
bymonth=(4, 7),
byyearday=(-365, -266, -166, -1),
dtstart=parse("19970902T090000"))),
[datetime(1998, 4, 10, 0, 0),
datetime(1998, 4, 10, 0, 1),
datetime(1998, 4, 10, 0, 2),
datetime(1998, 4, 10, 0, 3)])
def testMinutelyByWeekNo(self):
self.assertEqual(list(rrule(MINUTELY,
count=3,
byweekno=20,
dtstart=parse("19970902T090000"))),
[datetime(1998, 5, 11, 0, 0),
datetime(1998, 5, 11, 0, 1),
datetime(1998, 5, 11, 0, 2)])
def testMinutelyByWeekNoAndWeekDay(self):
self.assertEqual(list(rrule(MINUTELY,
count=3,
byweekno=1,
byweekday=MO,
dtstart=parse("19970902T090000"))),
[datetime(1997, 12, 29, 0, 0),
datetime(1997, 12, 29, 0, 1),
datetime(1997, 12, 29, 0, 2)])
def testMinutelyByWeekNoAndWeekDayLarge(self):
self.assertEqual(list(rrule(MINUTELY,
count=3,
byweekno=52,
byweekday=SU,
dtstart=parse("19970902T090000"))),
[datetime(1997, 12, 28, 0, 0),
datetime(1997, 12, 28, 0, 1),
datetime(1997, 12, 28, 0, 2)])
def testMinutelyByWeekNoAndWeekDayLast(self):
self.assertEqual(list(rrule(MINUTELY,
count=3,
byweekno=-1,
byweekday=SU,
dtstart=parse("19970902T090000"))),
[datetime(1997, 12, 28, 0, 0),
datetime(1997, 12, 28, 0, 1),
datetime(1997, 12, 28, 0, 2)])
def testMinutelyByWeekNoAndWeekDay53(self):
self.assertEqual(list(rrule(MINUTELY,
count=3,
byweekno=53,
byweekday=MO,
dtstart=parse("19970902T090000"))),
[datetime(1998, 12, 28, 0, 0),
datetime(1998, 12, 28, 0, 1),
datetime(1998, 12, 28, 0, 2)])
def testMinutelyByEaster(self):
self.assertEqual(list(rrule(MINUTELY,
count=3,
byeaster=0,
dtstart=parse("19970902T090000"))),
[datetime(1998, 4, 12, 0, 0),
datetime(1998, 4, 12, 0, 1),
datetime(1998, 4, 12, 0, 2)])
def testMinutelyByEasterPos(self):
self.assertEqual(list(rrule(MINUTELY,
count=3,
byeaster=1,
dtstart=parse("19970902T090000"))),
[datetime(1998, 4, 13, 0, 0),
datetime(1998, 4, 13, 0, 1),
datetime(1998, 4, 13, 0, 2)])
def testMinutelyByEasterNeg(self):
self.assertEqual(list(rrule(MINUTELY,
count=3,
byeaster=-1,
dtstart=parse("19970902T090000"))),
[datetime(1998, 4, 11, 0, 0),
datetime(1998, 4, 11, 0, 1),
datetime(1998, 4, 11, 0, 2)])
def testMinutelyByHour(self):
self.assertEqual(list(rrule(MINUTELY,
count=3,
byhour=(6, 18),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 18, 0),
datetime(1997, 9, 2, 18, 1),
datetime(1997, 9, 2, 18, 2)])
def testMinutelyByMinute(self):
self.assertEqual(list(rrule(MINUTELY,
count=3,
byminute=(6, 18),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 9, 6),
datetime(1997, 9, 2, 9, 18),
datetime(1997, 9, 2, 10, 6)])
def testMinutelyBySecond(self):
self.assertEqual(list(rrule(MINUTELY,
count=3,
bysecond=(6, 18),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 9, 0, 6),
datetime(1997, 9, 2, 9, 0, 18),
datetime(1997, 9, 2, 9, 1, 6)])
def testMinutelyByHourAndMinute(self):
self.assertEqual(list(rrule(MINUTELY,
count=3,
byhour=(6, 18),
byminute=(6, 18),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 18, 6),
datetime(1997, 9, 2, 18, 18),
datetime(1997, 9, 3, 6, 6)])
def testMinutelyByHourAndSecond(self):
self.assertEqual(list(rrule(MINUTELY,
count=3,
byhour=(6, 18),
bysecond=(6, 18),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 18, 0, 6),
datetime(1997, 9, 2, 18, 0, 18),
datetime(1997, 9, 2, 18, 1, 6)])
def testMinutelyByMinuteAndSecond(self):
self.assertEqual(list(rrule(MINUTELY,
count=3,
byminute=(6, 18),
bysecond=(6, 18),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 9, 6, 6),
datetime(1997, 9, 2, 9, 6, 18),
datetime(1997, 9, 2, 9, 18, 6)])
def testMinutelyByHourAndMinuteAndSecond(self):
self.assertEqual(list(rrule(MINUTELY,
count=3,
byhour=(6, 18),
byminute=(6, 18),
bysecond=(6, 18),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 18, 6, 6),
datetime(1997, 9, 2, 18, 6, 18),
datetime(1997, 9, 2, 18, 18, 6)])
def testMinutelyBySetPos(self):
self.assertEqual(list(rrule(MINUTELY,
count=3,
bysecond=(15, 30, 45),
bysetpos=(3, -3),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 9, 0, 15),
datetime(1997, 9, 2, 9, 0, 45),
datetime(1997, 9, 2, 9, 1, 15)])
def testSecondly(self):
self.assertEqual(list(rrule(SECONDLY,
count=3,
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 9, 0, 0),
datetime(1997, 9, 2, 9, 0, 1),
datetime(1997, 9, 2, 9, 0, 2)])
def testSecondlyInterval(self):
self.assertEqual(list(rrule(SECONDLY,
count=3,
interval=2,
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 9, 0, 0),
datetime(1997, 9, 2, 9, 0, 2),
datetime(1997, 9, 2, 9, 0, 4)])
def testSecondlyIntervalLarge(self):
self.assertEqual(list(rrule(SECONDLY,
count=3,
interval=90061,
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 9, 0, 0),
datetime(1997, 9, 3, 10, 1, 1),
datetime(1997, 9, 4, 11, 2, 2)])
def testSecondlyByMonth(self):
self.assertEqual(list(rrule(SECONDLY,
count=3,
bymonth=(1, 3),
dtstart=parse("19970902T090000"))),
[datetime(1998, 1, 1, 0, 0, 0),
datetime(1998, 1, 1, 0, 0, 1),
datetime(1998, 1, 1, 0, 0, 2)])
def testSecondlyByMonthDay(self):
self.assertEqual(list(rrule(SECONDLY,
count=3,
bymonthday=(1, 3),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 3, 0, 0, 0),
datetime(1997, 9, 3, 0, 0, 1),
datetime(1997, 9, 3, 0, 0, 2)])
def testSecondlyByMonthAndMonthDay(self):
self.assertEqual(list(rrule(SECONDLY,
count=3,
bymonth=(1, 3),
bymonthday=(5, 7),
dtstart=parse("19970902T090000"))),
[datetime(1998, 1, 5, 0, 0, 0),
datetime(1998, 1, 5, 0, 0, 1),
datetime(1998, 1, 5, 0, 0, 2)])
def testSecondlyByWeekDay(self):
self.assertEqual(list(rrule(SECONDLY,
count=3,
byweekday=(TU, TH),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 9, 0, 0),
datetime(1997, 9, 2, 9, 0, 1),
datetime(1997, 9, 2, 9, 0, 2)])
def testSecondlyByNWeekDay(self):
self.assertEqual(list(rrule(SECONDLY,
count=3,
byweekday=(TU(1), TH(-1)),
dtstart=parse("19970902T090000"))),
[datetime(1997, 9, 2, 9, 0, 0),
datetime(1997, 9, 2, 9, 0, 1),
datetime(1997, 9, 2, 9, 0, 2)])
def testSecondlyByMonthAndWeekDay(self):
self.assertEqual(list(rrule(SECONDLY,
count=3,
bymonth=(1, 3),
byweekday=(TU, TH),
dtstart=parse("19970902T090000"))),
[datetime(1998, 1, 1, 0, 0, 0),
datetime(1998, 1, 1, 0, 0, 1),
datetime(1998, 1, 1, 0, 0, 2)])
def testSecondlyByMonthAndNWeekDay(self):
self.assertEqual(list(rrule(SECONDLY,
count=3,
bymonth=(1, 3),
byweekday=(TU(1), TH(-1)),
dtstart=parse("19970902T090000"))),
[datetime(1998, 1, 1, 0, 0, 0),
datetime(1998, 1, 1, 0, 0, 1),
datetime(1998, 1, 1, 0, 0, 2)])
def testSecondlyByMonthDayAndWeekDay(self):
self.assertEqual(list(rrule(SECONDLY,
count=3,
bymonthday=(1, 3),
byweekday=(TU, TH),
dtstart=parse("19970902T090000"))),
[datetime(1998, 1, 1, 0, 0, 0),
datetime(1998, 1, 1, 0, 0, 1),
datetime(1998, 1, 1, 0, 0, 2)])
def testSecondlyByMonthAndMonthDayAndWeekDay(self):
self.assertEqual(list(rrule(SECONDLY,
count=3,
bymonth=(1, 3),
bymonthday=(1, 3),
byweekday=(TU, TH),
dtstart=parse("19970902T090000"))),
[datetime(1998, 1, 1, 0, 0, 0),
datetime(1998, 1, 1, 0, 0, 1),
datetime(1998, 1, 1, 0, 0, 2)])
def testSecondlyByYearDay(self):
self.assertEqual(list(rrule(SECONDLY,
count=4,
byyearday=(1, 100, 200, 365),
dtstart=parse("19970902T090000"))),
[datetime(1997, 12, 31, 0, 0, 0),
datetime(1997, 12, 31, 0, 0, 1),
datetime(1997, 12, 31, 0, 0, 2),
datetime(1997, 12, 31, 0, 0, 3)])
def testSecondlyByYearDayNeg(self):
self.assertEqual(list(rrule(SECONDLY,
count=4,
byyearday=(-365, -266, -166, -1),
dtstart=parse("19970902T090000"))),
[datetime(1997, 12, 31, 0, 0, 0),
datetime(1997, 12, 31, 0, 0, 1),
datetime(1997, 12, 31, 0, 0, 2),
datetime(1997, 12, 31, 0, 0, 3)])
def testSecondlyByMonthAndYearDay(self):
self.assertEqual(list(rrule(SECONDLY,
count=4,
bymonth=(4, 7),
byyearday=(1, 100, 200, 365),
dtstart=parse("19970902T090000"))),
[datetime(1998, 4, 10, 0, 0, 0),
datetime(1998, 4, 10, 0, 0, 1),
datetime(1998, 4, 10, 0, 0, 2),
datetime(1998, 4, 10, 0, 0, 3)])
def testSecondlyByMonthAndYearDayNeg(self):
self.assertEqual(list(rrule(SECONDLY,
count=4,
bymonth=(4, 7),
byyearday=(-365, -266, -166, -1),
dtstart=parse("19970902T090000"))),
[datetime(1998, 4, 10, 0, 0, 0),
datetime(1998, 4, 10, 0, 0, 1),
datetime(1998, 4, 10, 0, 0, 2),
datetime(1998, 4, 10, 0, 0, 3)])
def testSecondlyByWeekNo(self):
self.assertEqual(list(rrule(SECONDLY,
count=3,
byweekno=20<