本文整理匯總了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)