当前位置: 首页>>代码示例>>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;未经允许,请勿转载。