本文整理汇总了Python中calendar.firstweekday方法的典型用法代码示例。如果您正苦于以下问题:Python calendar.firstweekday方法的具体用法?Python calendar.firstweekday怎么用?Python calendar.firstweekday使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类calendar
的用法示例。
在下文中一共展示了calendar.firstweekday方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_setfirstweekday
# 需要导入模块: import calendar [as 别名]
# 或者: from calendar import firstweekday [as 别名]
def test_setfirstweekday(self):
self.assertRaises(ValueError, calendar.setfirstweekday, 'flabber')
self.assertRaises(ValueError, calendar.setfirstweekday, -1)
self.assertRaises(ValueError, calendar.setfirstweekday, 200)
orig = calendar.firstweekday()
calendar.setfirstweekday(calendar.SUNDAY)
self.assertEqual(calendar.firstweekday(), calendar.SUNDAY)
calendar.setfirstweekday(calendar.MONDAY)
self.assertEqual(calendar.firstweekday(), calendar.MONDAY)
calendar.setfirstweekday(orig)
示例2: test_itermonthdays
# 需要导入模块: import calendar [as 别名]
# 或者: from calendar import firstweekday [as 别名]
def test_itermonthdays(self):
for firstweekday in range(7):
cal = calendar.Calendar(firstweekday)
# Test the extremes, see #28253 and #26650
for y, m in [(1, 1), (9999, 12)]:
days = list(cal.itermonthdays(y, m))
self.assertIn(len(days), (35, 42))
# Test a short month
cal = calendar.Calendar(firstweekday=3)
days = list(cal.itermonthdays(2001, 2))
self.assertEqual(days, list(range(1, 29)))
示例3: test_itermonthdays2
# 需要导入模块: import calendar [as 别名]
# 或者: from calendar import firstweekday [as 别名]
def test_itermonthdays2(self):
for firstweekday in range(7):
cal = calendar.Calendar(firstweekday)
# Test the extremes, see #28253 and #26650
for y, m in [(1, 1), (9999, 12)]:
days = list(cal.itermonthdays2(y, m))
self.assertEqual(days[0][1], firstweekday)
self.assertEqual(days[-1][1], (firstweekday - 1) % 7)
示例4: setUp
# 需要导入模块: import calendar [as 别名]
# 或者: from calendar import firstweekday [as 别名]
def setUp(self):
self.oldfirstweekday = calendar.firstweekday()
calendar.setfirstweekday(self.firstweekday)
示例5: test_setfirstweekday
# 需要导入模块: import calendar [as 别名]
# 或者: from calendar import firstweekday [as 别名]
def test_setfirstweekday(self):
self.assertRaises(TypeError, calendar.setfirstweekday, 'flabber')
self.assertRaises(ValueError, calendar.setfirstweekday, -1)
self.assertRaises(ValueError, calendar.setfirstweekday, 200)
orig = calendar.firstweekday()
calendar.setfirstweekday(calendar.SUNDAY)
self.assertEqual(calendar.firstweekday(), calendar.SUNDAY)
calendar.setfirstweekday(calendar.MONDAY)
self.assertEqual(calendar.firstweekday(), calendar.MONDAY)
calendar.setfirstweekday(orig)
示例6: wkst
# 需要导入模块: import calendar [as 别名]
# 或者: from calendar import firstweekday [as 别名]
def wkst(self):
"""
The week start day. The default week start is got from
calendar.firstweekday() which Joyous sets based on the Django
FIRST_DAY_OF_WEEK format.
"""
return Weekday(self.rule._wkst)