Saturday, 9 July 2016

Python: TextCalendar: pryear: print the calendar for entire year

pryear(theyear, w=2, l=1, c=6, m=3)
Print the calendar for entire year. It internally uses ‘formatyear’ method. ‘w’ specifies date column width, ‘l’ specifies lines per week, ‘c’ specifies number spaces between month columns.
>>> from calendar import TextCalendar
>>> cal1=TextCalendar()
>>> 
>>> cal1.pryear(2011)
                                  2011

      January                   February                   March
Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su
                1  2          1  2  3  4  5  6          1  2  3  4  5  6
 3  4  5  6  7  8  9       7  8  9 10 11 12 13       7  8  9 10 11 12 13
10 11 12 13 14 15 16      14 15 16 17 18 19 20      14 15 16 17 18 19 20
17 18 19 20 21 22 23      21 22 23 24 25 26 27      21 22 23 24 25 26 27
24 25 26 27 28 29 30      28                        28 29 30 31
31

       April                      May                       June
Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su
             1  2  3                         1             1  2  3  4  5
 4  5  6  7  8  9 10       2  3  4  5  6  7  8       6  7  8  9 10 11 12
11 12 13 14 15 16 17       9 10 11 12 13 14 15      13 14 15 16 17 18 19
18 19 20 21 22 23 24      16 17 18 19 20 21 22      20 21 22 23 24 25 26
25 26 27 28 29 30         23 24 25 26 27 28 29      27 28 29 30
                          30 31

        July                     August                  September
Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su
             1  2  3       1  2  3  4  5  6  7                1  2  3  4
 4  5  6  7  8  9 10       8  9 10 11 12 13 14       5  6  7  8  9 10 11
11 12 13 14 15 16 17      15 16 17 18 19 20 21      12 13 14 15 16 17 18
18 19 20 21 22 23 24      22 23 24 25 26 27 28      19 20 21 22 23 24 25
25 26 27 28 29 30 31      29 30 31                  26 27 28 29 30

      October                   November                  December
Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su
                1  2          1  2  3  4  5  6                1  2  3  4
 3  4  5  6  7  8  9       7  8  9 10 11 12 13       5  6  7  8  9 10 11
10 11 12 13 14 15 16      14 15 16 17 18 19 20      12 13 14 15 16 17 18
17 18 19 20 21 22 23      21 22 23 24 25 26 27      19 20 21 22 23 24 25
24 25 26 27 28 29 30      28 29 30                  26 27 28 29 30 31
31

>>> 
>>> cal1.pryear(2011,m=5)
                                                            2011

      January                   February                   March                     April                      May
Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su
                1  2          1  2  3  4  5  6          1  2  3  4  5  6                   1  2  3                         1
 3  4  5  6  7  8  9       7  8  9 10 11 12 13       7  8  9 10 11 12 13       4  5  6  7  8  9 10       2  3  4  5  6  7  8
10 11 12 13 14 15 16      14 15 16 17 18 19 20      14 15 16 17 18 19 20      11 12 13 14 15 16 17       9 10 11 12 13 14 15
17 18 19 20 21 22 23      21 22 23 24 25 26 27      21 22 23 24 25 26 27      18 19 20 21 22 23 24      16 17 18 19 20 21 22
24 25 26 27 28 29 30      28                        28 29 30 31               25 26 27 28 29 30         23 24 25 26 27 28 29
31                                                                                                      30 31

        June                      July                     August                  September                  October
Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su
       1  2  3  4  5                   1  2  3       1  2  3  4  5  6  7                1  2  3  4                      1  2
 6  7  8  9 10 11 12       4  5  6  7  8  9 10       8  9 10 11 12 13 14       5  6  7  8  9 10 11       3  4  5  6  7  8  9
13 14 15 16 17 18 19      11 12 13 14 15 16 17      15 16 17 18 19 20 21      12 13 14 15 16 17 18      10 11 12 13 14 15 16
20 21 22 23 24 25 26      18 19 20 21 22 23 24      22 23 24 25 26 27 28      19 20 21 22 23 24 25      17 18 19 20 21 22 23
27 28 29 30               25 26 27 28 29 30 31      29 30 31                  26 27 28 29 30            24 25 26 27 28 29 30
                                                                                                        31

      November                  December
Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su
    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


Previous                                                 Next                                                 Home

No comments:

Post a Comment