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


Python calendar.setfirstweekday方法代碼示例

本文整理匯總了Python中calendar.setfirstweekday方法的典型用法代碼示例。如果您正苦於以下問題:Python calendar.setfirstweekday方法的具體用法?Python calendar.setfirstweekday怎麽用?Python calendar.setfirstweekday使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在calendar的用法示例。


在下文中一共展示了calendar.setfirstweekday方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_setfirstweekday

# 需要導入模塊: import calendar [as 別名]
# 或者: from calendar import setfirstweekday [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: setUp

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

示例3: tearDown

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

示例4: get_calendar

# 需要導入模塊: import calendar [as 別名]
# 或者: from calendar import setfirstweekday [as 別名]
def get_calendar(year, month):
    blank_week = [0, 0, 0, 0, 0, 0, 0]
    calendar.setfirstweekday(calendar.SUNDAY)
    c = calendar.monthcalendar(year, month)
    if len(c) == 4:
        c.append(blank_week)
    if len(c) == 5:
        c.append(blank_week)
    return c 
開發者ID:vitorfs,項目名稱:woid,代碼行數:11,代碼來源:calendar_helpers.py

示例5: month_calendar

# 需要導入模塊: import calendar [as 別名]
# 或者: from calendar import setfirstweekday [as 別名]
def month_calendar(year, month, days, service):
    calendar.setfirstweekday(calendar.SUNDAY)
    month_calendar = calendar.monthcalendar(int(year), int(month))

    month_name = calendar.month_name[int(month)]
    month_href = reverse('services:month', args=(service.slug, year, month))

    html = '<table><thead>'
    html += '<tr><th colspan="7"><a href="{0}">{1}</a></th></tr>'.format(month_href, month_name)
    html += '<tr><th>s</th><th>m</th><th>t</th><th>w</th><th>t</th><th>f</th><th>s</th></tr>'
    html += '</thead><tbody>'
    for week in month_calendar:
        html += '<tr>'
        for day in week:
            if day == 0:
                str_day = ''
            else:
                str_day = str(day).zfill(2)
            if str_day in days:
                day_href = reverse('services:day', args=(service.slug, year, month, str_day))
                html += '<td><a href="{0}">{1}</a></td>'.format(day_href, str_day)
            else:
                html += '<td>{0}</td>'.format(str_day)
        html += '</tr>'
    html += '</tbody></table>'
    return mark_safe(html) 
開發者ID:vitorfs,項目名稱:woid,代碼行數:28,代碼來源:calendar_helpers.py

示例6: setfirstweekday

# 需要導入模塊: import calendar [as 別名]
# 或者: from calendar import setfirstweekday [as 別名]
def setfirstweekday(weekday: int) -> None:
        calendar.setfirstweekday(weekday) 
開發者ID:Kartones,項目名稱:flask-calendar,代碼行數:4,代碼來源:gregorian_calendar.py

示例7: test_setfirstweekday

# 需要導入模塊: import calendar [as 別名]
# 或者: from calendar import setfirstweekday [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

示例8: test_illegal_weekday_reported

# 需要導入模塊: import calendar [as 別名]
# 或者: from calendar import setfirstweekday [as 別名]
def test_illegal_weekday_reported(self):
        with self.assertRaisesRegex(calendar.IllegalWeekdayError, '123'):
            calendar.setfirstweekday(123) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:5,代碼來源:test_calendar.py

示例9: __init__

# 需要導入模塊: import calendar [as 別名]
# 或者: from calendar import setfirstweekday [as 別名]
def __init__(self, month, year, indent_level, indent_style):
        'x.__init__(...) initializes x'
        calendar.setfirstweekday(calendar.SUNDAY)
        matrix = calendar.monthcalendar(year, month)
        self.__table = HTML_Table(len(matrix) + 1, 7, indent_level, indent_style)
        for column, text in enumerate(calendar.day_name[-1:] + calendar.day_name[:-1]):
            self.__table.mutate(0, column, '<b>%s</b>' % text)
        for row, week in enumerate(matrix):
            for column, day in enumerate(week):
                if day:
                    self.__table.mutate(row + 1, column, '<b>%02d</b>\n<hr>\n' % day)
        self.__weekday, self.__alldays = calendar.monthrange(year, month)
        self.__weekday = ((self.__weekday + 1) % 7) + 6 
開發者ID:ActiveState,項目名稱:code,代碼行數:15,代碼來源:recipe-496862.py


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