Python calendar.setfirstweekday() Examples

The following are 30 code examples of calendar.setfirstweekday(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module calendar , or try the search function .
Example #1
Source File: test_calendar.py    From medicare-demo with Apache License 2.0 6 votes vote down vote up
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) 
Example #2
Source File: test_calendar.py    From gcblue with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
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) 
Example #3
Source File: test_calendar.py    From ironpython3 with Apache License 2.0 6 votes vote down vote up
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) 
Example #4
Source File: test_calendar.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 6 votes vote down vote up
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) 
Example #5
Source File: test_calendar.py    From Fluid-Designer with GNU General Public License v3.0 6 votes vote down vote up
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) 
Example #6
Source File: test_calendar.py    From oss-ftp with MIT License 6 votes vote down vote up
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) 
Example #7
Source File: test_calendar.py    From CTFCrackTools-V2 with GNU General Public License v3.0 6 votes vote down vote up
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) 
Example #8
Source File: test_calendar.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
def tearDown(self):
        calendar.setfirstweekday(self.oldfirstweekday) 
Example #9
Source File: test_calendar.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
def setUp(self):
        self.oldfirstweekday = calendar.firstweekday()
        calendar.setfirstweekday(self.firstweekday) 
Example #10
Source File: test_calendar.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def setUp(self):
        self.oldfirstweekday = calendar.firstweekday()
        calendar.setfirstweekday(self.firstweekday) 
Example #11
Source File: test_calendar.py    From ironpython3 with Apache License 2.0 5 votes vote down vote up
def setUp(self):
        self.oldfirstweekday = calendar.firstweekday()
        calendar.setfirstweekday(self.firstweekday) 
Example #12
Source File: test_calendar.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
def tearDown(self):
        calendar.setfirstweekday(self.oldfirstweekday) 
Example #13
Source File: test_calendar.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def tearDown(self):
        calendar.setfirstweekday(self.oldfirstweekday) 
Example #14
Source File: test_calendar.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
def setUp(self):
        self.oldfirstweekday = calendar.firstweekday()
        calendar.setfirstweekday(self.firstweekday) 
Example #15
Source File: test_calendar.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
def test_illegal_weekday_reported(self):
        with self.assertRaisesRegex(calendar.IllegalWeekdayError, '123'):
            calendar.setfirstweekday(123) 
Example #16
Source File: test_calendar.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
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) 
Example #17
Source File: test_calendar.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def setUp(self):
        self.oldfirstweekday = calendar.firstweekday()
        calendar.setfirstweekday(self.firstweekday) 
Example #18
Source File: test_calendar.py    From gcblue with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def tearDown(self):
        calendar.setfirstweekday(self.oldfirstweekday) 
Example #19
Source File: test_calendar.py    From gcblue with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def setUp(self):
        self.oldfirstweekday = calendar.firstweekday()
        calendar.setfirstweekday(self.firstweekday) 
Example #20
Source File: test_calendar.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def tearDown(self):
        calendar.setfirstweekday(self.oldfirstweekday) 
Example #21
Source File: test_calendar.py    From oss-ftp with MIT License 5 votes vote down vote up
def setUp(self):
        self.oldfirstweekday = calendar.firstweekday()
        calendar.setfirstweekday(self.firstweekday) 
Example #22
Source File: test_calendar.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def setUp(self):
        self.oldfirstweekday = calendar.firstweekday()
        calendar.setfirstweekday(self.firstweekday) 
Example #23
Source File: test_calendar.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def tearDown(self):
        calendar.setfirstweekday(self.oldfirstweekday) 
Example #24
Source File: calendar_helpers.py    From woid with Apache License 2.0 5 votes vote down vote up
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 
Example #25
Source File: calendar_helpers.py    From woid with Apache License 2.0 5 votes vote down vote up
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) 
Example #26
Source File: gregorian_calendar.py    From flask-calendar with The Unlicense 5 votes vote down vote up
def setfirstweekday(weekday: int) -> None:
        calendar.setfirstweekday(weekday) 
Example #27
Source File: test_calendar.py    From BinderFilter with MIT License 5 votes vote down vote up
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) 
Example #28
Source File: test_calendar.py    From BinderFilter with MIT License 5 votes vote down vote up
def setUp(self):
        self.oldfirstweekday = calendar.firstweekday()
        calendar.setfirstweekday(self.firstweekday) 
Example #29
Source File: test_calendar.py    From BinderFilter with MIT License 5 votes vote down vote up
def tearDown(self):
        calendar.setfirstweekday(self.oldfirstweekday) 
Example #30
Source File: recipe-496862.py    From code with MIT License 5 votes vote down vote up
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