當前位置: 首頁>>代碼示例>>Python>>正文


Python calendar.firstweekday方法代碼示例

本文整理匯總了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) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:12,代碼來源:test_calendar.py

示例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))) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:13,代碼來源:test_calendar.py

示例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) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:10,代碼來源:test_calendar.py

示例4: setUp

# 需要導入模塊: import calendar [as 別名]
# 或者: from calendar import firstweekday [as 別名]
def setUp(self):
        self.oldfirstweekday = calendar.firstweekday()
        calendar.setfirstweekday(self.firstweekday) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:5,代碼來源:test_calendar.py

示例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) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:12,代碼來源:test_calendar.py

示例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) 
開發者ID:linuxsoftware,項目名稱:ls.joyous,代碼行數:9,代碼來源:recurrence.py


注:本文中的calendar.firstweekday方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。