本文整理汇总了Python中schedule.periods.Month.next_year方法的典型用法代码示例。如果您正苦于以下问题:Python Month.next_year方法的具体用法?Python Month.next_year怎么用?Python Month.next_year使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类schedule.periods.Month
的用法示例。
在下文中一共展示了Month.next_year方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestMonth
# 需要导入模块: from schedule.periods import Month [as 别名]
# 或者: from schedule.periods.Month import next_year [as 别名]
class TestMonth(TestCase):
def setUp(self):
rule = Rule(frequency="WEEKLY")
rule.save()
cal = Calendar(name="MyCal")
cal.save()
data = {
"title": "Recent Event",
"start": datetime.datetime(2008, 1, 5, 8, 0),
"end": datetime.datetime(2008, 1, 5, 9, 0),
"end_recurring_period": datetime.datetime(2008, 5, 5, 0, 0),
"rule": rule,
"calendar": cal,
}
recurring_event = Event(**data)
recurring_event.save()
self.month = Month(events=Event.objects.all(), date=datetime.datetime(2008, 2, 7, 9, 0))
def test_get_weeks(self):
weeks = self.month.get_weeks()
self.assertEqual(
[(week.start, week.end) for week in weeks],
[
(datetime.datetime(2008, 1, 27, 0, 0), datetime.datetime(2008, 2, 3, 0, 0)),
(datetime.datetime(2008, 2, 3, 0, 0), datetime.datetime(2008, 2, 10, 0, 0)),
(datetime.datetime(2008, 2, 10, 0, 0), datetime.datetime(2008, 2, 17, 0, 0)),
(datetime.datetime(2008, 2, 17, 0, 0), datetime.datetime(2008, 2, 24, 0, 0)),
(datetime.datetime(2008, 2, 24, 0, 0), datetime.datetime(2008, 3, 2, 0, 0)),
],
)
def test_get_days(self):
weeks = self.month.get_weeks()
week = weeks[0]
days = week.get_days()
self.assertEqual(
[(len(day.occurrences), day.start, day.end) for day in days],
[
(0, datetime.datetime(2008, 1, 27, 0, 0), datetime.datetime(2008, 1, 28, 0, 0)),
(0, datetime.datetime(2008, 1, 28, 0, 0), datetime.datetime(2008, 1, 29, 0, 0)),
(0, datetime.datetime(2008, 1, 29, 0, 0), datetime.datetime(2008, 1, 30, 0, 0)),
(0, datetime.datetime(2008, 1, 30, 0, 0), datetime.datetime(2008, 1, 31, 0, 0)),
(0, datetime.datetime(2008, 1, 31, 0, 0), datetime.datetime(2008, 2, 1, 0, 0)),
(0, datetime.datetime(2008, 2, 1, 0, 0), datetime.datetime(2008, 2, 2, 0, 0)),
(1, datetime.datetime(2008, 2, 2, 0, 0), datetime.datetime(2008, 2, 3, 0, 0)),
],
)
def test_month_convenience_functions(self):
self.assertEqual(self.month.prev_month(), datetime.datetime(2008, 1, 1, 0, 0))
self.assertEqual(self.month.next_month(), datetime.datetime(2008, 3, 1, 0, 0))
self.assertEqual(self.month.current_year(), datetime.datetime(2008, 1, 1, 0, 0))
self.assertEqual(self.month.prev_year(), datetime.datetime(2007, 1, 1, 0, 0))
self.assertEqual(self.month.next_year(), datetime.datetime(2009, 1, 1, 0, 0))
示例2: TestMonth
# 需要导入模块: from schedule.periods import Month [as 别名]
# 或者: from schedule.periods.Month import next_year [as 别名]
#.........这里部分代码省略.........
datetime.datetime(2008, 2, 3, 0, 0, tzinfo=pytz.utc)),
(datetime.datetime(2008, 2, 3, 0, 0, tzinfo=pytz.utc),
datetime.datetime(2008, 2, 10, 0, 0, tzinfo=pytz.utc)),
(datetime.datetime(2008, 2, 10, 0, 0, tzinfo=pytz.utc),
datetime.datetime(2008, 2, 17, 0, 0, tzinfo=pytz.utc)),
(datetime.datetime(2008, 2, 17, 0, 0, tzinfo=pytz.utc),
datetime.datetime(2008, 2, 24, 0, 0, tzinfo=pytz.utc)),
(datetime.datetime(2008, 2, 24, 0, 0, tzinfo=pytz.utc),
datetime.datetime(2008, 3, 2, 0, 0, tzinfo=pytz.utc))
]
else:
expecteds = [
(datetime.datetime(2008, 1, 28, 0, 0, tzinfo=pytz.utc),
datetime.datetime(2008, 2, 4, 0, 0, tzinfo=pytz.utc)),
(datetime.datetime(2008, 2, 4, 0, 0, tzinfo=pytz.utc),
datetime.datetime(2008, 2, 11, 0, 0, tzinfo=pytz.utc)),
(datetime.datetime(2008, 2, 11, 0, 0, tzinfo=pytz.utc),
datetime.datetime(2008, 2, 18, 0, 0, tzinfo=pytz.utc)),
(datetime.datetime(2008, 2, 18, 0, 0, tzinfo=pytz.utc),
datetime.datetime(2008, 2, 25, 0, 0, tzinfo=pytz.utc)),
(datetime.datetime(2008, 2, 25, 0, 0, tzinfo=pytz.utc),
datetime.datetime(2008, 3, 3, 0, 0, tzinfo=pytz.utc))
]
for actual, expected in zip(actuals, expecteds):
self.assertEqual(actual, expected)
def test_get_days(self):
weeks = self.month.get_weeks()
week = list(weeks)[0]
days = week.get_days()
actuals = [(len(day.occurrences), day.start,day.end) for day in days]
if settings.FIRST_DAY_OF_WEEK == 0:
expecteds = [
(
0,
datetime.datetime(2008, 1, 27, 0, 0, tzinfo=pytz.utc),
datetime.datetime(2008, 1, 28, 0, 0, tzinfo=pytz.utc)
),
(
0,
datetime.datetime(2008, 1, 28, 0, 0, tzinfo=pytz.utc),
datetime.datetime(2008, 1, 29, 0, 0, tzinfo=pytz.utc)
),
(
0,
datetime.datetime(2008, 1, 29, 0, 0, tzinfo=pytz.utc),
datetime.datetime(2008, 1, 30, 0, 0, tzinfo=pytz.utc)
),
(
0,
datetime.datetime(2008, 1, 30, 0, 0, tzinfo=pytz.utc),
datetime.datetime(2008, 1, 31, 0, 0, tzinfo=pytz.utc)
),
(
0,
datetime.datetime(2008, 1, 31, 0, 0, tzinfo=pytz.utc),
datetime.datetime(2008, 2, 1, 0, 0, tzinfo=pytz.utc)
),
(
0,
datetime.datetime(2008, 2, 1, 0, 0, tzinfo=pytz.utc),
datetime.datetime(2008, 2, 2, 0, 0, tzinfo=pytz.utc)
),
(
1,
datetime.datetime(2008, 2, 2, 0, 0, tzinfo=pytz.utc),
datetime.datetime(2008, 2, 3, 0, 0, tzinfo=pytz.utc)
),
]
else:
expecteds = [
(0, datetime.datetime(2008, 1, 28, 0, 0, tzinfo=pytz.utc),
datetime.datetime(2008, 1, 29, 0, 0, tzinfo=pytz.utc)),
(0, datetime.datetime(2008, 1, 29, 0, 0, tzinfo=pytz.utc),
datetime.datetime(2008, 1, 30, 0, 0, tzinfo=pytz.utc)),
(0, datetime.datetime(2008, 1, 30, 0, 0, tzinfo=pytz.utc),
datetime.datetime(2008, 1, 31, 0, 0, tzinfo=pytz.utc)),
(0, datetime.datetime(2008, 1, 31, 0, 0, tzinfo=pytz.utc),
datetime.datetime(2008, 2, 1, 0, 0, tzinfo=pytz.utc)),
(0, datetime.datetime(2008, 2, 1, 0, 0, tzinfo=pytz.utc),
datetime.datetime(2008, 2, 2, 0, 0, tzinfo=pytz.utc)),
(1, datetime.datetime(2008, 2, 2, 0, 0, tzinfo=pytz.utc),
datetime.datetime(2008, 2, 3, 0, 0, tzinfo=pytz.utc)),
(0, datetime.datetime(2008, 2, 3, 0, 0, tzinfo=pytz.utc),
datetime.datetime(2008, 2, 4, 0, 0, tzinfo=pytz.utc))
]
for actual, expected in zip(actuals, expecteds):
self.assertEqual(actual, expected)
def test_month_convenience_functions(self):
self.assertEqual( self.month.prev_month().start, datetime.datetime(2008, 1, 1, 0, 0, tzinfo=pytz.utc))
self.assertEqual( self.month.next_month().start, datetime.datetime(2008, 3, 1, 0, 0, tzinfo=pytz.utc))
self.assertEqual( self.month.current_year().start, datetime.datetime(2008, 1, 1, 0, 0, tzinfo=pytz.utc))
self.assertEqual( self.month.prev_year().start, datetime.datetime(2007, 1, 1, 0, 0, tzinfo=pytz.utc))
self.assertEqual( self.month.next_year().start, datetime.datetime(2009, 1, 1, 0, 0, tzinfo=pytz.utc))
示例3: TestMonth
# 需要导入模块: from schedule.periods import Month [as 别名]
# 或者: from schedule.periods.Month import next_year [as 别名]
class TestMonth(TestCase):
def setUp(self):
rule = Rule(frequency="WEEKLY")
rule.save()
cal = Room(name="MyCal")
cal.save()
data = {
"title": "Recent Reservation",
"start": datetime.datetime(2008, 1, 5, 8, 0),
"end": datetime.datetime(2008, 1, 5, 9, 0),
"end_recurring_period": datetime.datetime(2008, 5, 5, 0, 0),
"rule": rule,
"room": cal,
}
recurring_reservation = Reservation(**data)
recurring_reservation.save()
self.month = Month(reservations=Reservation.objects.all(), date=datetime.datetime(2008, 2, 7, 9, 0))
def test_get_weeks(self):
weeks = self.month.get_weeks()
actuals = [(week.start, week.end) for week in weeks]
if FIRST_DAY_OF_WEEK == 0:
expecteds = [
(datetime.datetime(2008, 1, 27, 0, 0), datetime.datetime(2008, 2, 3, 0, 0)),
(datetime.datetime(2008, 2, 3, 0, 0), datetime.datetime(2008, 2, 10, 0, 0)),
(datetime.datetime(2008, 2, 10, 0, 0), datetime.datetime(2008, 2, 17, 0, 0)),
(datetime.datetime(2008, 2, 17, 0, 0), datetime.datetime(2008, 2, 24, 0, 0)),
(datetime.datetime(2008, 2, 24, 0, 0), datetime.datetime(2008, 3, 2, 0, 0)),
]
else:
expecteds = [
(datetime.datetime(2008, 1, 28, 0, 0), datetime.datetime(2008, 2, 4, 0, 0)),
(datetime.datetime(2008, 2, 4, 0, 0), datetime.datetime(2008, 2, 11, 0, 0)),
(datetime.datetime(2008, 2, 11, 0, 0), datetime.datetime(2008, 2, 18, 0, 0)),
(datetime.datetime(2008, 2, 18, 0, 0), datetime.datetime(2008, 2, 25, 0, 0)),
(datetime.datetime(2008, 2, 25, 0, 0), datetime.datetime(2008, 3, 3, 0, 0)),
]
for actual, expected in zip(actuals, expecteds):
self.assertEqual(actual, expected)
def test_get_days(self):
weeks = self.month.get_weeks()
week = list(weeks)[0]
days = week.get_days()
actuals = [(len(day.occurrences), day.start, day.end) for day in days]
if FIRST_DAY_OF_WEEK == 0:
expecteds = [
(0, datetime.datetime(2008, 1, 27, 0, 0), datetime.datetime(2008, 1, 28, 0, 0)),
(0, datetime.datetime(2008, 1, 28, 0, 0), datetime.datetime(2008, 1, 29, 0, 0)),
(0, datetime.datetime(2008, 1, 29, 0, 0), datetime.datetime(2008, 1, 30, 0, 0)),
(0, datetime.datetime(2008, 1, 30, 0, 0), datetime.datetime(2008, 1, 31, 0, 0)),
(0, datetime.datetime(2008, 1, 31, 0, 0), datetime.datetime(2008, 2, 1, 0, 0)),
(0, datetime.datetime(2008, 2, 1, 0, 0), datetime.datetime(2008, 2, 2, 0, 0)),
(1, datetime.datetime(2008, 2, 2, 0, 0), datetime.datetime(2008, 2, 3, 0, 0)),
]
else:
expecteds = [
(0, datetime.datetime(2008, 1, 28, 0, 0), datetime.datetime(2008, 1, 29, 0, 0)),
(0, datetime.datetime(2008, 1, 29, 0, 0), datetime.datetime(2008, 1, 30, 0, 0)),
(0, datetime.datetime(2008, 1, 30, 0, 0), datetime.datetime(2008, 1, 31, 0, 0)),
(0, datetime.datetime(2008, 1, 31, 0, 0), datetime.datetime(2008, 2, 1, 0, 0)),
(0, datetime.datetime(2008, 2, 1, 0, 0), datetime.datetime(2008, 2, 2, 0, 0)),
(1, datetime.datetime(2008, 2, 2, 0, 0), datetime.datetime(2008, 2, 3, 0, 0)),
(0, datetime.datetime(2008, 2, 3, 0, 0), datetime.datetime(2008, 2, 4, 0, 0)),
]
for actual, expected in zip(actuals, expecteds):
self.assertEqual(actual, expected)
def test_month_convenience_functions(self):
self.assertEqual(self.month.prev_month().start, datetime.datetime(2008, 1, 1, 0, 0))
self.assertEqual(self.month.next_month().start, datetime.datetime(2008, 3, 1, 0, 0))
self.assertEqual(self.month.current_year().start, datetime.datetime(2008, 1, 1, 0, 0))
self.assertEqual(self.month.prev_year().start, datetime.datetime(2007, 1, 1, 0, 0))
self.assertEqual(self.month.next_year().start, datetime.datetime(2009, 1, 1, 0, 0))