pryear()

Calendar Module

theyearYear number for which calendar of the month is returned
mOptional, default =3,Number of columns of Months in a row
wOptional, default =2, width of date column
lOptional, default =0, number of line each week will use
pryear() : prints a string of yearly calendar as multi-line string.

import calendar
x=calendar.TextCalendar()  
x.pryear(theyear=2020,w=3,l=0,m=2)
Output

                            2020

          January                          February
Mon Tue Wed Thu Fri Sat Sun      Mon Tue Wed Thu Fri Sat Sun
          1   2   3   4   5                            1   2
  6   7   8   9  10  11  12        3   4   5   6   7   8   9
 13  14  15  16  17  18  19       10  11  12  13  14  15  16
 20  21  22  23  24  25  26       17  18  19  20  21  22  23
 27  28  29  30  31               24  25  26  27  28  29

           March                            April
Mon Tue Wed Thu Fri Sat Sun      Mon Tue Wed Thu Fri Sat Sun
                          1                1   2   3   4   5
  2   3   4   5   6   7   8        6   7   8   9  10  11  12
  9  10  11  12  13  14  15       13  14  15  16  17  18  19
 16  17  18  19  20  21  22       20  21  22  23  24  25  26
 23  24  25  26  27  28  29       27  28  29  30
 30  31

            May                              June
Mon Tue Wed Thu Fri Sat Sun      Mon Tue Wed Thu Fri Sat Sun
                  1   2   3        1   2   3   4   5   6   7
  4   5   6   7   8   9  10        8   9  10  11  12  13  14
 11  12  13  14  15  16  17       15  16  17  18  19  20  21
 18  19  20  21  22  23  24       22  23  24  25  26  27  28
 25  26  27  28  29  30  31       29  30

            July                            August
Mon Tue Wed Thu Fri Sat Sun      Mon Tue Wed Thu Fri Sat Sun
          1   2   3   4   5                            1   2
  6   7   8   9  10  11  12        3   4   5   6   7   8   9
 13  14  15  16  17  18  19       10  11  12  13  14  15  16
 20  21  22  23  24  25  26       17  18  19  20  21  22  23
 27  28  29  30  31               24  25  26  27  28  29  30
                                  31

         September                         October
Mon Tue Wed Thu Fri Sat Sun      Mon Tue Wed Thu Fri Sat Sun
      1   2   3   4   5   6                    1   2   3   4
  7   8   9  10  11  12  13        5   6   7   8   9  10  11
 14  15  16  17  18  19  20       12  13  14  15  16  17  18
 21  22  23  24  25  26  27       19  20  21  22  23  24  25
 28  29  30                       26  27  28  29  30  31

          November                         December
Mon Tue Wed Thu Fri Sat Sun      Mon Tue Wed Thu Fri Sat Sun
                          1            1   2   3   4   5   6
  2   3   4   5   6   7   8        7   8   9  10  11  12  13
  9  10  11  12  13  14  15       14  15  16  17  18  19  20
 16  17  18  19  20  21  22       21  22  23  24  25  26  27
 23  24  25  26  27  28  29       28  29  30  31
 30
Based on the setting of first day of the week, the calendar first weekday can be set. Week day number starts from 0 as Monday , 1 as Tuesday and ends at 6 as Sunday.
import calendar
x=calendar.TextCalendar() 
x.setfirstweekday(4) # first week day is Friday
x.pryear(theyear=2020,w=3,l=0,m=2)
Output
                            2020

          January                          February
Fri Sat Sun Mon Tue Wed Thu      Fri Sat Sun Mon Tue Wed Thu
                      1   2            1   2   3   4   5   6
  3   4   5   6   7   8   9        7   8   9  10  11  12  13
 10  11  12  13  14  15  16       14  15  16  17  18  19  20
 17  18  19  20  21  22  23       21  22  23  24  25  26  27
 24  25  26  27  28  29  30       28  29
 31

           March                            April
Fri Sat Sun Mon Tue Wed Thu      Fri Sat Sun Mon Tue Wed Thu
          1   2   3   4   5                            1   2
  6   7   8   9  10  11  12        3   4   5   6   7   8   9
 13  14  15  16  17  18  19       10  11  12  13  14  15  16
 20  21  22  23  24  25  26       17  18  19  20  21  22  23
 27  28  29  30  31               24  25  26  27  28  29  30

            May                              June
Fri Sat Sun Mon Tue Wed Thu      Fri Sat Sun Mon Tue Wed Thu
  1   2   3   4   5   6   7                    1   2   3   4
  8   9  10  11  12  13  14        5   6   7   8   9  10  11
 15  16  17  18  19  20  21       12  13  14  15  16  17  18
 22  23  24  25  26  27  28       19  20  21  22  23  24  25
 29  30  31                       26  27  28  29  30

            July                            August
Fri Sat Sun Mon Tue Wed Thu      Fri Sat Sun Mon Tue Wed Thu
                      1   2            1   2   3   4   5   6
  3   4   5   6   7   8   9        7   8   9  10  11  12  13
 10  11  12  13  14  15  16       14  15  16  17  18  19  20
 17  18  19  20  21  22  23       21  22  23  24  25  26  27
 24  25  26  27  28  29  30       28  29  30  31
 31

         September                         October
Fri Sat Sun Mon Tue Wed Thu      Fri Sat Sun Mon Tue Wed Thu
                  1   2   3                                1
  4   5   6   7   8   9  10        2   3   4   5   6   7   8
 11  12  13  14  15  16  17        9  10  11  12  13  14  15
 18  19  20  21  22  23  24       16  17  18  19  20  21  22
 25  26  27  28  29  30           23  24  25  26  27  28  29
                                  30  31

          November                         December
Fri Sat Sun Mon Tue Wed Thu      Fri Sat Sun Mon Tue Wed Thu
          1   2   3   4   5                        1   2   3
  6   7   8   9  10  11  12        4   5   6   7   8   9  10
 13  14  15  16  17  18  19       11  12  13  14  15  16  17
 20  21  22  23  24  25  26       18  19  20  21  22  23  24
 27  28  29  30                   25  26  27  28  29  30  31
Calendar Module in Python itermonthdays() itermonthdays2() itermonthdays3()




plus2net.com



Post your comments , suggestion , error , requirements etc here




We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
©2000-2020 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer