File size: 113,803 Bytes
dcac338
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
<!DOCTYPE html>

<html lang="en" data-content_root="../">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
<meta property="og:title" content="calendar — General calendar-related functions" />
<meta property="og:type" content="website" />
<meta property="og:url" content="https://docs.python.org/3/library/calendar.html" />
<meta property="og:site_name" content="Python documentation" />
<meta property="og:description" content="Source code: Lib/calendar.py This module allows you to output calendars like the Unix cal program, and provides additional useful functions related to the calendar. By default, these calendars have..." />
<meta property="og:image:width" content="1146" />
<meta property="og:image:height" content="600" />
<meta property="og:image" content="https://docs.python.org/3.15/_images/social_previews/summary_library_calendar_7181f47a.png" />
<meta property="og:image:alt" content="Source code: Lib/calendar.py This module allows you to output calendars like the Unix cal program, and provides additional useful functions related to the calendar. By default, these calendars have..." />
<meta name="description" content="Source code: Lib/calendar.py This module allows you to output calendars like the Unix cal program, and provides additional useful functions related to the calendar. By default, these calendars have..." />
<meta name="twitter:card" content="summary_large_image" />
<meta name="theme-color" content="#3776ab">

    <title>calendar — General calendar-related functions &#8212; Python 3.15.0a6 documentation</title><meta name="viewport" content="width=device-width, initial-scale=1.0">
    
    <link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=b86133f3" />
    <link rel="stylesheet" type="text/css" href="../_static/classic.css?v=234b1a7c" />
    <link rel="stylesheet" type="text/css" href="../_static/pydoctheme.css?v=89a2f22a" />
    <link rel="stylesheet" type="text/css" href="../_static/profiling-sampling-visualization.css?v=0c2600ae" />
    <link id="pygments_dark_css" media="(prefers-color-scheme: dark)" rel="stylesheet" type="text/css" href="../_static/pygments_dark.css?v=5349f25f" />
    
    <script src="../_static/documentation_options.js?v=6b7c9ff5"></script>
    <script src="../_static/doctools.js?v=9bcbadda"></script>
    <script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
    <script src="../_static/profiling-sampling-visualization.js?v=9811ed04"></script>
    
    <script src="../_static/sidebar.js"></script>
    
    <link rel="search" type="application/opensearchdescription+xml"
          title="Search within Python 3.15.0a6 documentation"
          href="../_static/opensearch.xml"/>
    <link rel="author" title="About these documents" href="../about.html" />
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="copyright" title="Copyright" href="../copyright.html" />
    <link rel="next" title="collections — Container datatypes" href="collections.html" />
    <link rel="prev" title="zoneinfo — IANA time zone support" href="zoneinfo.html" />
    
      
      <script defer file-types="bz2,epub,zip" data-domain="docs.python.org" src="https://analytics.python.org/js/script.file-downloads.outbound-links.js"></script>
      
      <link rel="canonical" href="https://docs.python.org/3/library/calendar.html">
      
    

    
    <style>
      @media only screen {
        table.full-width-table {
            width: 100%;
        }
      }
    </style>
<link rel="stylesheet" href="../_static/pydoctheme_dark.css" media="(prefers-color-scheme: dark)" id="pydoctheme_dark_css">
    <link rel="shortcut icon" type="image/png" href="../_static/py.svg">
            <script type="text/javascript" src="../_static/copybutton.js"></script>
            <script type="text/javascript" src="../_static/menu.js"></script>
            <script type="text/javascript" src="../_static/search-focus.js"></script>
            <script type="text/javascript" src="../_static/themetoggle.js"></script> 
            <script type="text/javascript" src="../_static/rtd_switcher.js"></script>
            <meta name="readthedocs-addons-api-version" content="1">

  </head>
<body>
<div class="mobile-nav">
    <input type="checkbox" id="menuToggler" class="toggler__input" aria-controls="navigation"
           aria-pressed="false" aria-expanded="false" role="button" aria-label="Menu">
    <nav class="nav-content" role="navigation">
        <label for="menuToggler" class="toggler__label">
            <span></span>
        </label>
        <span class="nav-items-wrapper">
            <a href="https://www.python.org/" class="nav-logo">
                <img src="../_static/py.svg" alt="Python logo">
            </a>
            <span class="version_switcher_placeholder"></span>
            <form role="search" class="search" action="../search.html" method="get">
                <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" class="search-icon">
                    <path fill-rule="nonzero" fill="currentColor" d="M15.5 14h-.79l-.28-.27a6.5 6.5 0 001.48-5.34c-.47-2.78-2.79-5-5.59-5.34a6.505 6.505 0 00-7.27 7.27c.34 2.8 2.56 5.12 5.34 5.59a6.5 6.5 0 005.34-1.48l.27.28v.79l4.25 4.25c.41.41 1.08.41 1.49 0 .41-.41.41-1.08 0-1.49L15.5 14zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"></path>
                </svg>
                <input placeholder="Quick search" aria-label="Quick search" type="search" name="q">
                <input type="submit" value="Go">
            </form>
        </span>
    </nav>
    <div class="menu-wrapper">
        <nav class="menu" role="navigation" aria-label="main navigation">
            <div class="language_switcher_placeholder"></div>
            
<label class="theme-selector-label">
    Theme
    <select class="theme-selector" oninput="activateTheme(this.value)">
        <option value="auto" selected>Auto</option>
        <option value="light">Light</option>
        <option value="dark">Dark</option>
    </select>
</label>
  <div>
    <h3><a href="../contents.html">Table of Contents</a></h3>
    <ul>
<li><a class="reference internal" href="#"><code class="xref py py-mod docutils literal notranslate"><span class="pre">calendar</span></code> — General calendar-related functions</a><ul>
<li><a class="reference internal" href="#command-line-usage">Command-line usage</a></li>
</ul>
</li>
</ul>

  </div>
  <div>
    <h4>Previous topic</h4>
    <p class="topless"><a href="zoneinfo.html"
                          title="previous chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">zoneinfo</span></code> — IANA time zone support</a></p>
  </div>
  <div>
    <h4>Next topic</h4>
    <p class="topless"><a href="collections.html"
                          title="next chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">collections</span></code> — Container datatypes</a></p>
  </div>
  <script>
    document.addEventListener('DOMContentLoaded', () => {
        const title = document.querySelector('meta[property="og:title"]').content;
        const elements = document.querySelectorAll('.improvepage');
        const pageurl = window.location.href.split('?')[0];
        elements.forEach(element => {
            const url = new URL(element.href.split('?')[0].replace("-nojs", ""));
            url.searchParams.set('pagetitle', title);
            url.searchParams.set('pageurl', pageurl);
            url.searchParams.set('pagesource', "library/calendar.rst");
            element.href = url.toString();
        });
    });
  </script>
  <div role="note" aria-label="source link">
    <h3>This page</h3>
    <ul class="this-page-menu">
      <li><a href="../bugs.html">Report a bug</a></li>
      <li><a class="improvepage" href="../improve-page-nojs.html">Improve this page</a></li>
      <li>
        <a href="https://github.com/python/cpython/blob/main/Doc/library/calendar.rst?plain=1"
            rel="nofollow">Show source
        </a>
      </li>
      
    </ul>
  </div>
        </nav>
    </div>
</div>

  
    <div class="related" role="navigation" aria-label="Related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="collections.html" title="collections — Container datatypes"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="zoneinfo.html" title="zoneinfo — IANA time zone support"
             accesskey="P">previous</a> |</li>

          <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"></li>
          <li><a href="https://www.python.org/">Python</a> &#187;</li>
          <li class="switchers">
            <div class="language_switcher_placeholder"></div>
            <div class="version_switcher_placeholder"></div>
          </li>
          <li>
              
          </li>
    <li id="cpython-language-and-version">
      <a href="../index.html">3.15.0a6 Documentation</a> &#187;
    </li>

          <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="datatypes.html" accesskey="U">Data Types</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href=""><code class="xref py py-mod docutils literal notranslate"><span class="pre">calendar</span></code> — General calendar-related functions</a></li>
                <li class="right">
                    

    <div class="inline-search" role="search">
        <form class="inline-search" action="../search.html" method="get">
          <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box">
          <input type="submit" value="Go">
        </form>
    </div>
                     |
                </li>
            <li class="right">
<label class="theme-selector-label">
    Theme
    <select class="theme-selector" oninput="activateTheme(this.value)">
        <option value="auto" selected>Auto</option>
        <option value="light">Light</option>
        <option value="dark">Dark</option>
    </select>
</label> |</li>
            
      </ul>
    </div>    

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <section id="module-calendar">
<span id="calendar-general-calendar-related-functions"></span><h1><code class="xref py py-mod docutils literal notranslate"><span class="pre">calendar</span></code> — General calendar-related functions<a class="headerlink" href="#module-calendar" title="Link to this heading"></a></h1>
<p><strong>Source code:</strong> <a class="extlink-source reference external" href="https://github.com/python/cpython/tree/main/Lib/calendar.py">Lib/calendar.py</a></p>
<hr class="docutils" />
<p>This module allows you to output calendars like the Unix <strong class="program">cal</strong> program,
and provides additional useful functions related to the calendar. By default,
these calendars have Monday as the first day of the week, and Sunday as the last
(the European convention). Use <a class="reference internal" href="#calendar.setfirstweekday" title="calendar.setfirstweekday"><code class="xref py py-func docutils literal notranslate"><span class="pre">setfirstweekday()</span></code></a> to set the first day of
the week to Sunday (6) or to any other weekday.  Parameters that specify dates
are given as integers. For related
functionality, see also the <a class="reference internal" href="datetime.html#module-datetime" title="datetime: Basic date and time types."><code class="xref py py-mod docutils literal notranslate"><span class="pre">datetime</span></code></a> and <a class="reference internal" href="time.html#module-time" title="time: Time access and conversions."><code class="xref py py-mod docutils literal notranslate"><span class="pre">time</span></code></a> modules.</p>
<p>The functions and classes defined in this module
use an idealized calendar, the current Gregorian calendar extended indefinitely
in both directions.  This matches the definition of the “proleptic Gregorian”
calendar in Dershowitz and Reingold’s book “Calendrical Calculations”, where
it’s the base calendar for all computations.  Zero and negative years are
interpreted as prescribed by the ISO 8601 standard.  Year 0 is 1 BC, year -1 is
2 BC, and so on.</p>
<dl class="py class">
<dt class="sig sig-object py" id="calendar.Calendar">
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">Calendar</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">firstweekday</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.Calendar" title="Link to this definition"></a></dt>
<dd><p>Creates a <code class="xref py py-class docutils literal notranslate"><span class="pre">Calendar</span></code> object. <em>firstweekday</em> is an integer specifying the
first day of the week. <a class="reference internal" href="#calendar.MONDAY" title="calendar.MONDAY"><code class="xref py py-const docutils literal notranslate"><span class="pre">MONDAY</span></code></a> is <code class="docutils literal notranslate"><span class="pre">0</span></code> (the default), <a class="reference internal" href="#calendar.SUNDAY" title="calendar.SUNDAY"><code class="xref py py-const docutils literal notranslate"><span class="pre">SUNDAY</span></code></a> is <code class="docutils literal notranslate"><span class="pre">6</span></code>.</p>
<p>A <code class="xref py py-class docutils literal notranslate"><span class="pre">Calendar</span></code> object provides several methods that can be used for
preparing the calendar data for formatting. This class doesn’t do any formatting
itself. This is the job of subclasses.</p>
<p><code class="xref py py-class docutils literal notranslate"><span class="pre">Calendar</span></code> instances have the following methods and attributes:</p>
<dl class="py attribute">
<dt class="sig sig-object py" id="calendar.Calendar.firstweekday">
<span class="sig-name descname"><span class="pre">firstweekday</span></span><a class="headerlink" href="#calendar.Calendar.firstweekday" title="Link to this definition"></a></dt>
<dd><p>The first weekday as an integer (0–6).</p>
<p>This property can also be set and read using
<a class="reference internal" href="#calendar.Calendar.setfirstweekday" title="calendar.Calendar.setfirstweekday"><code class="xref py py-meth docutils literal notranslate"><span class="pre">setfirstweekday()</span></code></a> and
<a class="reference internal" href="#calendar.Calendar.getfirstweekday" title="calendar.Calendar.getfirstweekday"><code class="xref py py-meth docutils literal notranslate"><span class="pre">getfirstweekday()</span></code></a> respectively.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="calendar.Calendar.getfirstweekday">
<span class="sig-name descname"><span class="pre">getfirstweekday</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#calendar.Calendar.getfirstweekday" title="Link to this definition"></a></dt>
<dd><p>Return an <a class="reference internal" href="functions.html#int" title="int"><code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code></a> for the current first weekday (0–6).</p>
<p>Identical to reading the <a class="reference internal" href="#calendar.Calendar.firstweekday" title="calendar.Calendar.firstweekday"><code class="xref py py-attr docutils literal notranslate"><span class="pre">firstweekday</span></code></a> property.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="calendar.Calendar.setfirstweekday">
<span class="sig-name descname"><span class="pre">setfirstweekday</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">firstweekday</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.Calendar.setfirstweekday" title="Link to this definition"></a></dt>
<dd><p>Set the first weekday to <em>firstweekday</em>, passed as an <a class="reference internal" href="functions.html#int" title="int"><code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code></a> (0–6)</p>
<p>Identical to setting the <a class="reference internal" href="#calendar.Calendar.firstweekday" title="calendar.Calendar.firstweekday"><code class="xref py py-attr docutils literal notranslate"><span class="pre">firstweekday</span></code></a> property.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="calendar.Calendar.iterweekdays">
<span class="sig-name descname"><span class="pre">iterweekdays</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#calendar.Calendar.iterweekdays" title="Link to this definition"></a></dt>
<dd><p>Return an iterator for the week day numbers that will be used for one
week.  The first value from the iterator will be the same as the value of
the <a class="reference internal" href="#calendar.Calendar.firstweekday" title="calendar.Calendar.firstweekday"><code class="xref py py-attr docutils literal notranslate"><span class="pre">firstweekday</span></code></a> property.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="calendar.Calendar.itermonthdates">
<span class="sig-name descname"><span class="pre">itermonthdates</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">year</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">month</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.Calendar.itermonthdates" title="Link to this definition"></a></dt>
<dd><p>Return an iterator for the month <em>month</em> (1–12) in the year <em>year</em>. This
iterator will return all days (as <a class="reference internal" href="datetime.html#datetime.date" title="datetime.date"><code class="xref py py-class docutils literal notranslate"><span class="pre">datetime.date</span></code></a> objects) for the
month and all days before the start of the month or after the end of the
month that are required to get a complete week.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="calendar.Calendar.itermonthdays">
<span class="sig-name descname"><span class="pre">itermonthdays</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">year</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">month</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.Calendar.itermonthdays" title="Link to this definition"></a></dt>
<dd><p>Return an iterator for the month <em>month</em> in the year <em>year</em> similar to
<a class="reference internal" href="#calendar.Calendar.itermonthdates" title="calendar.Calendar.itermonthdates"><code class="xref py py-meth docutils literal notranslate"><span class="pre">itermonthdates()</span></code></a>, but not restricted by the <a class="reference internal" href="datetime.html#datetime.date" title="datetime.date"><code class="xref py py-class docutils literal notranslate"><span class="pre">datetime.date</span></code></a>
range. Days returned will simply be day of the month numbers.  For the
days outside of the specified month, the day number is <code class="docutils literal notranslate"><span class="pre">0</span></code>.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="calendar.Calendar.itermonthdays2">
<span class="sig-name descname"><span class="pre">itermonthdays2</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">year</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">month</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.Calendar.itermonthdays2" title="Link to this definition"></a></dt>
<dd><p>Return an iterator for the month <em>month</em> in the year <em>year</em> similar to
<a class="reference internal" href="#calendar.Calendar.itermonthdates" title="calendar.Calendar.itermonthdates"><code class="xref py py-meth docutils literal notranslate"><span class="pre">itermonthdates()</span></code></a>, but not restricted by the <a class="reference internal" href="datetime.html#datetime.date" title="datetime.date"><code class="xref py py-class docutils literal notranslate"><span class="pre">datetime.date</span></code></a>
range. Days returned will be tuples consisting of a day of the month
number and a week day number.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="calendar.Calendar.itermonthdays3">
<span class="sig-name descname"><span class="pre">itermonthdays3</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">year</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">month</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.Calendar.itermonthdays3" title="Link to this definition"></a></dt>
<dd><p>Return an iterator for the month <em>month</em> in the year <em>year</em> similar to
<a class="reference internal" href="#calendar.Calendar.itermonthdates" title="calendar.Calendar.itermonthdates"><code class="xref py py-meth docutils literal notranslate"><span class="pre">itermonthdates()</span></code></a>, but not restricted by the <a class="reference internal" href="datetime.html#datetime.date" title="datetime.date"><code class="xref py py-class docutils literal notranslate"><span class="pre">datetime.date</span></code></a>
range. Days returned will be tuples consisting of a year, a month and a day
of the month numbers.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.7.</span></p>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="calendar.Calendar.itermonthdays4">
<span class="sig-name descname"><span class="pre">itermonthdays4</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">year</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">month</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.Calendar.itermonthdays4" title="Link to this definition"></a></dt>
<dd><p>Return an iterator for the month <em>month</em> in the year <em>year</em> similar to
<a class="reference internal" href="#calendar.Calendar.itermonthdates" title="calendar.Calendar.itermonthdates"><code class="xref py py-meth docutils literal notranslate"><span class="pre">itermonthdates()</span></code></a>, but not restricted by the <a class="reference internal" href="datetime.html#datetime.date" title="datetime.date"><code class="xref py py-class docutils literal notranslate"><span class="pre">datetime.date</span></code></a>
range. Days returned will be tuples consisting of a year, a month, a day
of the month, and a day of the week numbers.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.7.</span></p>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="calendar.Calendar.monthdatescalendar">
<span class="sig-name descname"><span class="pre">monthdatescalendar</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">year</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">month</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.Calendar.monthdatescalendar" title="Link to this definition"></a></dt>
<dd><p>Return a list of the weeks in the month <em>month</em> of the <em>year</em> as full
weeks.  Weeks are lists of seven <a class="reference internal" href="datetime.html#datetime.date" title="datetime.date"><code class="xref py py-class docutils literal notranslate"><span class="pre">datetime.date</span></code></a> objects.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="calendar.Calendar.monthdays2calendar">
<span class="sig-name descname"><span class="pre">monthdays2calendar</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">year</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">month</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.Calendar.monthdays2calendar" title="Link to this definition"></a></dt>
<dd><p>Return a list of the weeks in the month <em>month</em> of the <em>year</em> as full
weeks.  Weeks are lists of seven tuples of day numbers and weekday
numbers.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="calendar.Calendar.monthdayscalendar">
<span class="sig-name descname"><span class="pre">monthdayscalendar</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">year</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">month</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.Calendar.monthdayscalendar" title="Link to this definition"></a></dt>
<dd><p>Return a list of the weeks in the month <em>month</em> of the <em>year</em> as full
weeks.  Weeks are lists of seven day numbers.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="calendar.Calendar.yeardatescalendar">
<span class="sig-name descname"><span class="pre">yeardatescalendar</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">year</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">width</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">3</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.Calendar.yeardatescalendar" title="Link to this definition"></a></dt>
<dd><p>Return the data for the specified year ready for formatting. The return
value is a list of month rows. Each month row contains up to <em>width</em>
months (defaulting to 3). Each month contains between 4 and 6 weeks and
each week contains 1–7 days. Days are <a class="reference internal" href="datetime.html#datetime.date" title="datetime.date"><code class="xref py py-class docutils literal notranslate"><span class="pre">datetime.date</span></code></a> objects.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="calendar.Calendar.yeardays2calendar">
<span class="sig-name descname"><span class="pre">yeardays2calendar</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">year</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">width</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">3</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.Calendar.yeardays2calendar" title="Link to this definition"></a></dt>
<dd><p>Return the data for the specified year ready for formatting (similar to
<a class="reference internal" href="#calendar.Calendar.yeardatescalendar" title="calendar.Calendar.yeardatescalendar"><code class="xref py py-meth docutils literal notranslate"><span class="pre">yeardatescalendar()</span></code></a>). Entries in the week lists are tuples of day
numbers and weekday numbers. Day numbers outside this month are zero.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="calendar.Calendar.yeardayscalendar">
<span class="sig-name descname"><span class="pre">yeardayscalendar</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">year</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">width</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">3</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.Calendar.yeardayscalendar" title="Link to this definition"></a></dt>
<dd><p>Return the data for the specified year ready for formatting (similar to
<a class="reference internal" href="#calendar.Calendar.yeardatescalendar" title="calendar.Calendar.yeardatescalendar"><code class="xref py py-meth docutils literal notranslate"><span class="pre">yeardatescalendar()</span></code></a>). Entries in the week lists are day numbers. Day
numbers outside this month are zero.</p>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="calendar.TextCalendar">
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">TextCalendar</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">firstweekday</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.TextCalendar" title="Link to this definition"></a></dt>
<dd><p>This class can be used to generate plain text calendars.</p>
<p><code class="xref py py-class docutils literal notranslate"><span class="pre">TextCalendar</span></code> instances have the following methods:</p>
<dl class="py method">
<dt class="sig sig-object py" id="calendar.TextCalendar.prweek">
<span class="sig-name descname"><span class="pre">prweek</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">theweek</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">width</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.TextCalendar.prweek" title="Link to this definition"></a></dt>
<dd><p>Print a week’s calendar as returned by <a class="reference internal" href="#calendar.TextCalendar.formatweek" title="calendar.TextCalendar.formatweek"><code class="xref py py-meth docutils literal notranslate"><span class="pre">formatweek()</span></code></a> and without a
final newline.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="calendar.TextCalendar.formatday">
<span class="sig-name descname"><span class="pre">formatday</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">theday</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">weekday</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">width</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.TextCalendar.formatday" title="Link to this definition"></a></dt>
<dd><p>Return a string representing a single day formatted with the given <em>width</em>.
If <em>theday</em> is <code class="docutils literal notranslate"><span class="pre">0</span></code>, return a string of spaces of
the specified width, representing an empty day. The <em>weekday</em> parameter
is unused.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="calendar.TextCalendar.formatweek">
<span class="sig-name descname"><span class="pre">formatweek</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">theweek</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">w</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.TextCalendar.formatweek" title="Link to this definition"></a></dt>
<dd><p>Return a single week in a string with no newline. If <em>w</em> is provided, it
specifies the width of the date columns, which are centered. Depends
on the first weekday as specified in the constructor or set by the
<a class="reference internal" href="#calendar.setfirstweekday" title="calendar.setfirstweekday"><code class="xref py py-meth docutils literal notranslate"><span class="pre">setfirstweekday()</span></code></a> method.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="calendar.TextCalendar.formatweekday">
<span class="sig-name descname"><span class="pre">formatweekday</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">weekday</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">width</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.TextCalendar.formatweekday" title="Link to this definition"></a></dt>
<dd><p>Return a string representing the name of a single weekday formatted to
the specified <em>width</em>. The <em>weekday</em> parameter is an integer representing
the day of the week, where <code class="docutils literal notranslate"><span class="pre">0</span></code> is Monday and <code class="docutils literal notranslate"><span class="pre">6</span></code> is Sunday.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="calendar.TextCalendar.formatweekheader">
<span class="sig-name descname"><span class="pre">formatweekheader</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">width</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.TextCalendar.formatweekheader" title="Link to this definition"></a></dt>
<dd><p>Return a string containing the header row of weekday names, formatted
with the given <em>width</em> for each column. The names depend on the locale
settings and are padded to the specified width.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="calendar.TextCalendar.formatmonth">
<span class="sig-name descname"><span class="pre">formatmonth</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">theyear</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">themonth</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">w</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">l</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.TextCalendar.formatmonth" title="Link to this definition"></a></dt>
<dd><p>Return a month’s calendar in a multi-line string. If <em>w</em> is provided, it
specifies the width of the date columns, which are centered. If <em>l</em> is
given, it specifies the number of lines that each week will use. Depends
on the first weekday as specified in the constructor or set by the
<a class="reference internal" href="#calendar.setfirstweekday" title="calendar.setfirstweekday"><code class="xref py py-meth docutils literal notranslate"><span class="pre">setfirstweekday()</span></code></a> method.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="calendar.TextCalendar.formatmonthname">
<span class="sig-name descname"><span class="pre">formatmonthname</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">theyear</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">themonth</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">width</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">withyear</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.TextCalendar.formatmonthname" title="Link to this definition"></a></dt>
<dd><p>Return a string representing the month’s name centered within the
specified <em>width</em>. If <em>withyear</em> is <code class="docutils literal notranslate"><span class="pre">True</span></code>, include the year in the
output. The <em>theyear</em> and <em>themonth</em> parameters specify the year
and month for the name to be formatted respectively.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="calendar.TextCalendar.prmonth">
<span class="sig-name descname"><span class="pre">prmonth</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">theyear</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">themonth</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">w</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">l</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.TextCalendar.prmonth" title="Link to this definition"></a></dt>
<dd><p>Print a month’s calendar as returned by <a class="reference internal" href="#calendar.TextCalendar.formatmonth" title="calendar.TextCalendar.formatmonth"><code class="xref py py-meth docutils literal notranslate"><span class="pre">formatmonth()</span></code></a>.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="calendar.TextCalendar.formatyear">
<span class="sig-name descname"><span class="pre">formatyear</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">theyear</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">w</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">2</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">l</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">c</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">6</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">m</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">3</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.TextCalendar.formatyear" title="Link to this definition"></a></dt>
<dd><p>Return a <em>m</em>-column calendar for an entire year as a multi-line string.
Optional parameters <em>w</em>, <em>l</em>, and <em>c</em> are for date column width, lines per
week, and number of spaces between month columns, respectively. Depends on
the first weekday as specified in the constructor or set by the
<a class="reference internal" href="#calendar.setfirstweekday" title="calendar.setfirstweekday"><code class="xref py py-meth docutils literal notranslate"><span class="pre">setfirstweekday()</span></code></a> method.  The earliest year for which a calendar
can be generated is platform-dependent.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="calendar.TextCalendar.pryear">
<span class="sig-name descname"><span class="pre">pryear</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">theyear</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">w</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">2</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">l</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">c</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">6</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">m</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">3</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.TextCalendar.pryear" title="Link to this definition"></a></dt>
<dd><p>Print the calendar for an entire year as returned by <a class="reference internal" href="#calendar.TextCalendar.formatyear" title="calendar.TextCalendar.formatyear"><code class="xref py py-meth docutils literal notranslate"><span class="pre">formatyear()</span></code></a>.</p>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="calendar.HTMLCalendar">
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">HTMLCalendar</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">firstweekday</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.HTMLCalendar" title="Link to this definition"></a></dt>
<dd><p>This class can be used to generate HTML calendars.</p>
<p><code class="xref py py-class docutils literal notranslate"><span class="pre">HTMLCalendar</span></code> instances have the following methods:</p>
<dl class="py method">
<dt class="sig sig-object py" id="calendar.HTMLCalendar.formatmonth">
<span class="sig-name descname"><span class="pre">formatmonth</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">theyear</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">themonth</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">withyear</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.HTMLCalendar.formatmonth" title="Link to this definition"></a></dt>
<dd><p>Return a month’s calendar as an HTML table. If <em>withyear</em> is true the year
will be included in the header, otherwise just the month name will be
used.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="calendar.HTMLCalendar.formatyear">
<span class="sig-name descname"><span class="pre">formatyear</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">theyear</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">width</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">3</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.HTMLCalendar.formatyear" title="Link to this definition"></a></dt>
<dd><p>Return a year’s calendar as an HTML table. <em>width</em> (defaulting to 3)
specifies the number of months per row.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="calendar.HTMLCalendar.formatyearpage">
<span class="sig-name descname"><span class="pre">formatyearpage</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">theyear</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">width</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">3</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">css</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'calendar.css'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">encoding</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.HTMLCalendar.formatyearpage" title="Link to this definition"></a></dt>
<dd><p>Return a year’s calendar as a complete HTML page. <em>width</em> (defaulting to
3) specifies the number of months per row. <em>css</em> is the name for the
cascading style sheet to be used. <a class="reference internal" href="constants.html#None" title="None"><code class="xref py py-const docutils literal notranslate"><span class="pre">None</span></code></a> can be passed if no style
sheet should be used. <em>encoding</em> specifies the encoding to be used for the
output (defaulting to <code class="docutils literal notranslate"><span class="pre">'utf-8'</span></code>).</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="calendar.HTMLCalendar.formatmonthname">
<span class="sig-name descname"><span class="pre">formatmonthname</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">theyear</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">themonth</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">withyear</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.HTMLCalendar.formatmonthname" title="Link to this definition"></a></dt>
<dd><p>Return a month name as an HTML table row. If <em>withyear</em> is true the year
will be included in the row, otherwise just the month name will be
used.</p>
</dd></dl>

<p><code class="xref py py-class docutils literal notranslate"><span class="pre">HTMLCalendar</span></code> has the following attributes you can override to
customize the CSS classes used by the calendar:</p>
<dl class="py attribute">
<dt class="sig sig-object py" id="calendar.HTMLCalendar.cssclasses">
<span class="sig-name descname"><span class="pre">cssclasses</span></span><a class="headerlink" href="#calendar.HTMLCalendar.cssclasses" title="Link to this definition"></a></dt>
<dd><p>A list of CSS classes used for each weekday. The default class list is:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="n">cssclasses</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;mon&quot;</span><span class="p">,</span> <span class="s2">&quot;tue&quot;</span><span class="p">,</span> <span class="s2">&quot;wed&quot;</span><span class="p">,</span> <span class="s2">&quot;thu&quot;</span><span class="p">,</span> <span class="s2">&quot;fri&quot;</span><span class="p">,</span> <span class="s2">&quot;sat&quot;</span><span class="p">,</span> <span class="s2">&quot;sun&quot;</span><span class="p">]</span>
</pre></div>
</div>
<p>more styles can be added for each day:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="n">cssclasses</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;mon text-bold&quot;</span><span class="p">,</span> <span class="s2">&quot;tue&quot;</span><span class="p">,</span> <span class="s2">&quot;wed&quot;</span><span class="p">,</span> <span class="s2">&quot;thu&quot;</span><span class="p">,</span> <span class="s2">&quot;fri&quot;</span><span class="p">,</span> <span class="s2">&quot;sat&quot;</span><span class="p">,</span> <span class="s2">&quot;sun red&quot;</span><span class="p">]</span>
</pre></div>
</div>
<p>Note that the length of this list must be seven items.</p>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="calendar.HTMLCalendar.cssclass_noday">
<span class="sig-name descname"><span class="pre">cssclass_noday</span></span><a class="headerlink" href="#calendar.HTMLCalendar.cssclass_noday" title="Link to this definition"></a></dt>
<dd><p>The CSS class for a weekday occurring in the previous or coming month.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.7.</span></p>
</div>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="calendar.HTMLCalendar.cssclasses_weekday_head">
<span class="sig-name descname"><span class="pre">cssclasses_weekday_head</span></span><a class="headerlink" href="#calendar.HTMLCalendar.cssclasses_weekday_head" title="Link to this definition"></a></dt>
<dd><p>A list of CSS classes used for weekday names in the header row.
The default is the same as <a class="reference internal" href="#calendar.HTMLCalendar.cssclasses" title="calendar.HTMLCalendar.cssclasses"><code class="xref py py-attr docutils literal notranslate"><span class="pre">cssclasses</span></code></a>.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.7.</span></p>
</div>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="calendar.HTMLCalendar.cssclass_month_head">
<span class="sig-name descname"><span class="pre">cssclass_month_head</span></span><a class="headerlink" href="#calendar.HTMLCalendar.cssclass_month_head" title="Link to this definition"></a></dt>
<dd><p>The month’s head CSS class (used by <a class="reference internal" href="#calendar.HTMLCalendar.formatmonthname" title="calendar.HTMLCalendar.formatmonthname"><code class="xref py py-meth docutils literal notranslate"><span class="pre">formatmonthname()</span></code></a>).
The default value is <code class="docutils literal notranslate"><span class="pre">&quot;month&quot;</span></code>.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.7.</span></p>
</div>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="calendar.HTMLCalendar.cssclass_month">
<span class="sig-name descname"><span class="pre">cssclass_month</span></span><a class="headerlink" href="#calendar.HTMLCalendar.cssclass_month" title="Link to this definition"></a></dt>
<dd><p>The CSS class for the whole month’s table (used by <a class="reference internal" href="#calendar.HTMLCalendar.formatmonth" title="calendar.HTMLCalendar.formatmonth"><code class="xref py py-meth docutils literal notranslate"><span class="pre">formatmonth()</span></code></a>).
The default value is <code class="docutils literal notranslate"><span class="pre">&quot;month&quot;</span></code>.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.7.</span></p>
</div>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="calendar.HTMLCalendar.cssclass_year">
<span class="sig-name descname"><span class="pre">cssclass_year</span></span><a class="headerlink" href="#calendar.HTMLCalendar.cssclass_year" title="Link to this definition"></a></dt>
<dd><p>The CSS class for the whole year’s table of tables (used by
<a class="reference internal" href="#calendar.HTMLCalendar.formatyear" title="calendar.HTMLCalendar.formatyear"><code class="xref py py-meth docutils literal notranslate"><span class="pre">formatyear()</span></code></a>). The default value is <code class="docutils literal notranslate"><span class="pre">&quot;year&quot;</span></code>.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.7.</span></p>
</div>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="calendar.HTMLCalendar.cssclass_year_head">
<span class="sig-name descname"><span class="pre">cssclass_year_head</span></span><a class="headerlink" href="#calendar.HTMLCalendar.cssclass_year_head" title="Link to this definition"></a></dt>
<dd><p>The CSS class for the table head for the whole year (used by
<a class="reference internal" href="#calendar.HTMLCalendar.formatyear" title="calendar.HTMLCalendar.formatyear"><code class="xref py py-meth docutils literal notranslate"><span class="pre">formatyear()</span></code></a>). The default value is <code class="docutils literal notranslate"><span class="pre">&quot;year&quot;</span></code>.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.7.</span></p>
</div>
</dd></dl>

<p>Note that although the naming for the above described class attributes is
singular (e.g. <code class="docutils literal notranslate"><span class="pre">cssclass_month</span></code> <code class="docutils literal notranslate"><span class="pre">cssclass_noday</span></code>), one can replace the
single CSS class with a space separated list of CSS classes, for example:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="s2">&quot;text-bold text-red&quot;</span>
</pre></div>
</div>
<p>Here is an example how <code class="xref py py-class docutils literal notranslate"><span class="pre">HTMLCalendar</span></code> can be customized:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="k">class</span><span class="w"> </span><span class="nc">CustomHTMLCal</span><span class="p">(</span><span class="n">calendar</span><span class="o">.</span><span class="n">HTMLCalendar</span><span class="p">):</span>
    <span class="n">cssclasses</span> <span class="o">=</span> <span class="p">[</span><span class="n">style</span> <span class="o">+</span> <span class="s2">&quot; text-nowrap&quot;</span> <span class="k">for</span> <span class="n">style</span> <span class="ow">in</span>
                  <span class="n">calendar</span><span class="o">.</span><span class="n">HTMLCalendar</span><span class="o">.</span><span class="n">cssclasses</span><span class="p">]</span>
    <span class="n">cssclass_month_head</span> <span class="o">=</span> <span class="s2">&quot;text-center month-head&quot;</span>
    <span class="n">cssclass_month</span> <span class="o">=</span> <span class="s2">&quot;text-center month&quot;</span>
    <span class="n">cssclass_year</span> <span class="o">=</span> <span class="s2">&quot;text-italic lead&quot;</span>
</pre></div>
</div>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="calendar.LocaleTextCalendar">
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">LocaleTextCalendar</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">firstweekday</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">locale</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.LocaleTextCalendar" title="Link to this definition"></a></dt>
<dd><p>This subclass of <a class="reference internal" href="#calendar.TextCalendar" title="calendar.TextCalendar"><code class="xref py py-class docutils literal notranslate"><span class="pre">TextCalendar</span></code></a> can be passed a locale name in the
constructor and will return month and weekday names in the specified locale.</p>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="calendar.LocaleHTMLCalendar">
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">LocaleHTMLCalendar</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">firstweekday</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">locale</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.LocaleHTMLCalendar" title="Link to this definition"></a></dt>
<dd><p>This subclass of <a class="reference internal" href="#calendar.HTMLCalendar" title="calendar.HTMLCalendar"><code class="xref py py-class docutils literal notranslate"><span class="pre">HTMLCalendar</span></code></a> can be passed a locale name in the
constructor and will return month and weekday names in the specified
locale.</p>
</dd></dl>

<div class="admonition note">
<p class="admonition-title">Note</p>
<p>The constructor, <code class="xref py py-meth docutils literal notranslate"><span class="pre">formatweekday()</span></code> and <code class="xref py py-meth docutils literal notranslate"><span class="pre">formatmonthname()</span></code> methods
of these two classes temporarily change the <code class="docutils literal notranslate"><span class="pre">LC_TIME</span></code> locale to the given
<em>locale</em>. Because the current locale is a process-wide setting, they are
not thread-safe.</p>
</div>
<p>For simple text calendars this module provides the following functions.</p>
<dl class="py function">
<dt class="sig sig-object py" id="calendar.setfirstweekday">
<span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">setfirstweekday</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">weekday</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.setfirstweekday" title="Link to this definition"></a></dt>
<dd><p>Sets the weekday (<code class="docutils literal notranslate"><span class="pre">0</span></code> is Monday, <code class="docutils literal notranslate"><span class="pre">6</span></code> is Sunday) to start each week. The
values <a class="reference internal" href="#calendar.MONDAY" title="calendar.MONDAY"><code class="xref py py-const docutils literal notranslate"><span class="pre">MONDAY</span></code></a>, <a class="reference internal" href="#calendar.TUESDAY" title="calendar.TUESDAY"><code class="xref py py-const docutils literal notranslate"><span class="pre">TUESDAY</span></code></a>, <a class="reference internal" href="#calendar.WEDNESDAY" title="calendar.WEDNESDAY"><code class="xref py py-const docutils literal notranslate"><span class="pre">WEDNESDAY</span></code></a>, <a class="reference internal" href="#calendar.THURSDAY" title="calendar.THURSDAY"><code class="xref py py-const docutils literal notranslate"><span class="pre">THURSDAY</span></code></a>,
<a class="reference internal" href="#calendar.FRIDAY" title="calendar.FRIDAY"><code class="xref py py-const docutils literal notranslate"><span class="pre">FRIDAY</span></code></a>, <a class="reference internal" href="#calendar.SATURDAY" title="calendar.SATURDAY"><code class="xref py py-const docutils literal notranslate"><span class="pre">SATURDAY</span></code></a>, and <a class="reference internal" href="#calendar.SUNDAY" title="calendar.SUNDAY"><code class="xref py py-const docutils literal notranslate"><span class="pre">SUNDAY</span></code></a> are provided for
convenience. For example, to set the first weekday to Sunday:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span><span class="w"> </span><span class="nn">calendar</span>
<span class="n">calendar</span><span class="o">.</span><span class="n">setfirstweekday</span><span class="p">(</span><span class="n">calendar</span><span class="o">.</span><span class="n">SUNDAY</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="calendar.firstweekday">
<span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">firstweekday</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#calendar.firstweekday" title="Link to this definition"></a></dt>
<dd><p>Returns the current setting for the weekday to start each week.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="calendar.isleap">
<span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">isleap</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">year</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.isleap" title="Link to this definition"></a></dt>
<dd><p>Returns <a class="reference internal" href="constants.html#True" title="True"><code class="xref py py-const docutils literal notranslate"><span class="pre">True</span></code></a> if <em>year</em> is a leap year, otherwise <a class="reference internal" href="constants.html#False" title="False"><code class="xref py py-const docutils literal notranslate"><span class="pre">False</span></code></a>.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="calendar.leapdays">
<span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">leapdays</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">y1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">y2</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.leapdays" title="Link to this definition"></a></dt>
<dd><p>Returns the number of leap years in the range from <em>y1</em> to <em>y2</em> (exclusive),
where <em>y1</em> and <em>y2</em> are years.</p>
<p>This function works for ranges spanning a century change.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="calendar.weekday">
<span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">weekday</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">year</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">month</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">day</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.weekday" title="Link to this definition"></a></dt>
<dd><p>Returns the day of the week (<code class="docutils literal notranslate"><span class="pre">0</span></code> is Monday) for <em>year</em> (<code class="docutils literal notranslate"><span class="pre">1970</span></code>–…),
<em>month</em> (<code class="docutils literal notranslate"><span class="pre">1</span></code><code class="docutils literal notranslate"><span class="pre">12</span></code>), <em>day</em> (<code class="docutils literal notranslate"><span class="pre">1</span></code><code class="docutils literal notranslate"><span class="pre">31</span></code>).</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="calendar.weekheader">
<span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">weekheader</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">n</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.weekheader" title="Link to this definition"></a></dt>
<dd><p>Return a header containing abbreviated weekday names. <em>n</em> specifies the width in
characters for one weekday.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="calendar.monthrange">
<span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">monthrange</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">year</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">month</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.monthrange" title="Link to this definition"></a></dt>
<dd><p>Returns weekday of first day of the month and number of days in month,  for the
specified <em>year</em> and <em>month</em>.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="calendar.monthcalendar">
<span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">monthcalendar</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">year</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">month</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.monthcalendar" title="Link to this definition"></a></dt>
<dd><p>Returns a matrix representing a month’s calendar.  Each row represents a week;
days outside of the month are represented by zeros. Each week begins with Monday
unless set by <a class="reference internal" href="#calendar.setfirstweekday" title="calendar.setfirstweekday"><code class="xref py py-func docutils literal notranslate"><span class="pre">setfirstweekday()</span></code></a>.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="calendar.prmonth">
<span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">prmonth</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">theyear</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">themonth</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">w</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">l</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.prmonth" title="Link to this definition"></a></dt>
<dd><p>Prints a month’s calendar as returned by <a class="reference internal" href="#calendar.month" title="calendar.month"><code class="xref py py-func docutils literal notranslate"><span class="pre">month()</span></code></a>.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="calendar.month">
<span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">month</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">theyear</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">themonth</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">w</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">l</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.month" title="Link to this definition"></a></dt>
<dd><p>Returns a month’s calendar in a multi-line string using the <a class="reference internal" href="#calendar.TextCalendar.formatmonth" title="calendar.TextCalendar.formatmonth"><code class="xref py py-meth docutils literal notranslate"><span class="pre">formatmonth()</span></code></a>
of the <a class="reference internal" href="#calendar.TextCalendar" title="calendar.TextCalendar"><code class="xref py py-class docutils literal notranslate"><span class="pre">TextCalendar</span></code></a> class.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="calendar.prcal">
<span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">prcal</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">year</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">w</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">l</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">c</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">6</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">m</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">3</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.prcal" title="Link to this definition"></a></dt>
<dd><p>Prints the calendar for an entire year as returned by  <a class="reference internal" href="#module-calendar" title="calendar: Functions for working with calendars, including some emulation of the Unix cal program."><code class="xref py py-func docutils literal notranslate"><span class="pre">calendar()</span></code></a>.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="calendar.calendar">
<span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">calendar</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">year</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">w</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">2</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">l</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">c</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">6</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">m</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">3</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.calendar" title="Link to this definition"></a></dt>
<dd><p>Returns a 3-column calendar for an entire year as a multi-line string using
the <a class="reference internal" href="#calendar.TextCalendar.formatyear" title="calendar.TextCalendar.formatyear"><code class="xref py py-meth docutils literal notranslate"><span class="pre">formatyear()</span></code></a> of the <a class="reference internal" href="#calendar.TextCalendar" title="calendar.TextCalendar"><code class="xref py py-class docutils literal notranslate"><span class="pre">TextCalendar</span></code></a> class.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="calendar.timegm">
<span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">timegm</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">tuple</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.timegm" title="Link to this definition"></a></dt>
<dd><p>An unrelated but handy function that takes a time tuple such as returned by
the <a class="reference internal" href="time.html#time.gmtime" title="time.gmtime"><code class="xref py py-func docutils literal notranslate"><span class="pre">gmtime()</span></code></a> function in the <a class="reference internal" href="time.html#module-time" title="time: Time access and conversions."><code class="xref py py-mod docutils literal notranslate"><span class="pre">time</span></code></a> module, and returns the
corresponding Unix timestamp value, assuming an epoch of 1970, and the POSIX
encoding.  In fact, <code class="xref py py-func docutils literal notranslate"><span class="pre">time.gmtime()</span></code> and <code class="xref py py-func docutils literal notranslate"><span class="pre">timegm()</span></code> are each others’
inverse.</p>
</dd></dl>

<p>The <code class="xref py py-mod docutils literal notranslate"><span class="pre">calendar</span></code> module exports the following data attributes:</p>
<dl class="py data">
<dt class="sig sig-object py" id="calendar.day_name">
<span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">day_name</span></span><a class="headerlink" href="#calendar.day_name" title="Link to this definition"></a></dt>
<dd><p>A sequence that represents the days of the week in the current locale,
where Monday is day number 0.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span><span class="w"> </span><span class="nn">calendar</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">list</span><span class="p">(</span><span class="n">calendar</span><span class="o">.</span><span class="n">day_name</span><span class="p">)</span>
<span class="go">[&#39;Monday&#39;, &#39;Tuesday&#39;, &#39;Wednesday&#39;, &#39;Thursday&#39;, &#39;Friday&#39;, &#39;Saturday&#39;, &#39;Sunday&#39;]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py data">
<dt class="sig sig-object py" id="calendar.day_abbr">
<span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">day_abbr</span></span><a class="headerlink" href="#calendar.day_abbr" title="Link to this definition"></a></dt>
<dd><p>A sequence that represents the abbreviated days of the week in the current locale,
where Mon is day number 0.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span><span class="w"> </span><span class="nn">calendar</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">list</span><span class="p">(</span><span class="n">calendar</span><span class="o">.</span><span class="n">day_abbr</span><span class="p">)</span>
<span class="go">[&#39;Mon&#39;, &#39;Tue&#39;, &#39;Wed&#39;, &#39;Thu&#39;, &#39;Fri&#39;, &#39;Sat&#39;, &#39;Sun&#39;]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py data">
<dt class="sig sig-object py" id="calendar.MONDAY">
<span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">MONDAY</span></span><a class="headerlink" href="#calendar.MONDAY" title="Link to this definition"></a></dt>
<dt class="sig sig-object py" id="calendar.TUESDAY">
<span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">TUESDAY</span></span><a class="headerlink" href="#calendar.TUESDAY" title="Link to this definition"></a></dt>
<dt class="sig sig-object py" id="calendar.WEDNESDAY">
<span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">WEDNESDAY</span></span><a class="headerlink" href="#calendar.WEDNESDAY" title="Link to this definition"></a></dt>
<dt class="sig sig-object py" id="calendar.THURSDAY">
<span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">THURSDAY</span></span><a class="headerlink" href="#calendar.THURSDAY" title="Link to this definition"></a></dt>
<dt class="sig sig-object py" id="calendar.FRIDAY">
<span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">FRIDAY</span></span><a class="headerlink" href="#calendar.FRIDAY" title="Link to this definition"></a></dt>
<dt class="sig sig-object py" id="calendar.SATURDAY">
<span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">SATURDAY</span></span><a class="headerlink" href="#calendar.SATURDAY" title="Link to this definition"></a></dt>
<dt class="sig sig-object py" id="calendar.SUNDAY">
<span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">SUNDAY</span></span><a class="headerlink" href="#calendar.SUNDAY" title="Link to this definition"></a></dt>
<dd><p>Aliases for the days of the week,
where <code class="docutils literal notranslate"><span class="pre">MONDAY</span></code> is <code class="docutils literal notranslate"><span class="pre">0</span></code> and <code class="docutils literal notranslate"><span class="pre">SUNDAY</span></code> is <code class="docutils literal notranslate"><span class="pre">6</span></code>.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.12.</span></p>
</div>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="calendar.Day">
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">Day</span></span><a class="headerlink" href="#calendar.Day" title="Link to this definition"></a></dt>
<dd><p>Enumeration defining days of the week as integer constants.
The members of this enumeration are exported to the module scope as
<a class="reference internal" href="#calendar.MONDAY" title="calendar.MONDAY"><code class="xref py py-data docutils literal notranslate"><span class="pre">MONDAY</span></code></a> through <a class="reference internal" href="#calendar.SUNDAY" title="calendar.SUNDAY"><code class="xref py py-data docutils literal notranslate"><span class="pre">SUNDAY</span></code></a>.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.12.</span></p>
</div>
</dd></dl>

<dl class="py data">
<dt class="sig sig-object py" id="calendar.month_name">
<span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">month_name</span></span><a class="headerlink" href="#calendar.month_name" title="Link to this definition"></a></dt>
<dd><p>A sequence that represents the months of the year in the current locale.  This
follows normal convention of January being month number 1, so it has a length of
13 and <code class="docutils literal notranslate"><span class="pre">month_name[0]</span></code> is the empty string.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span><span class="w"> </span><span class="nn">calendar</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">list</span><span class="p">(</span><span class="n">calendar</span><span class="o">.</span><span class="n">month_name</span><span class="p">)</span>
<span class="go">[&#39;&#39;, &#39;January&#39;, &#39;February&#39;, &#39;March&#39;, &#39;April&#39;, &#39;May&#39;, &#39;June&#39;, &#39;July&#39;, &#39;August&#39;, &#39;September&#39;, &#39;October&#39;, &#39;November&#39;, &#39;December&#39;]</span>
</pre></div>
</div>
<div class="admonition caution">
<p class="admonition-title">Caution</p>
<p>In locales with alternative month names forms, the <code class="xref py py-data docutils literal notranslate"><span class="pre">month_name</span></code> sequence
may not be suitable when a month name stands by itself and not as part of a date.
For instance, in Greek and in many Slavic and Baltic languages, <code class="xref py py-data docutils literal notranslate"><span class="pre">month_name</span></code>
will produce the month in genitive case. Use <a class="reference internal" href="#calendar.standalone_month_name" title="calendar.standalone_month_name"><code class="xref py py-data docutils literal notranslate"><span class="pre">standalone_month_name</span></code></a> for a form
suitable for standalone use.</p>
</div>
</dd></dl>

<dl class="py data">
<dt class="sig sig-object py" id="calendar.month_abbr">
<span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">month_abbr</span></span><a class="headerlink" href="#calendar.month_abbr" title="Link to this definition"></a></dt>
<dd><p>A sequence that represents the abbreviated months of the year in the current
locale.  This follows normal convention of January being month number 1, so it
has a length of 13 and  <code class="docutils literal notranslate"><span class="pre">month_abbr[0]</span></code> is the empty string.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span><span class="w"> </span><span class="nn">calendar</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">list</span><span class="p">(</span><span class="n">calendar</span><span class="o">.</span><span class="n">month_abbr</span><span class="p">)</span>
<span class="go">[&#39;&#39;, &#39;Jan&#39;, &#39;Feb&#39;, &#39;Mar&#39;, &#39;Apr&#39;, &#39;May&#39;, &#39;Jun&#39;, &#39;Jul&#39;, &#39;Aug&#39;, &#39;Sep&#39;, &#39;Oct&#39;, &#39;Nov&#39;, &#39;Dec&#39;]</span>
</pre></div>
</div>
<div class="admonition caution">
<p class="admonition-title">Caution</p>
<p>In locales with alternative month names forms, the <code class="xref py py-data docutils literal notranslate"><span class="pre">month_abbr</span></code> sequence
may not be suitable when a month name stands by itself and not as part of a date.
Use <a class="reference internal" href="#calendar.standalone_month_abbr" title="calendar.standalone_month_abbr"><code class="xref py py-data docutils literal notranslate"><span class="pre">standalone_month_abbr</span></code></a> for a form suitable for standalone use.</p>
</div>
</dd></dl>

<dl class="py data">
<dt class="sig sig-object py" id="calendar.standalone_month_name">
<span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">standalone_month_name</span></span><a class="headerlink" href="#calendar.standalone_month_name" title="Link to this definition"></a></dt>
<dd><p>A sequence that represents the months of the year in the current locale
in the standalone form if the locale provides one. Else it is equivalent
to <a class="reference internal" href="#calendar.month_name" title="calendar.month_name"><code class="xref py py-data docutils literal notranslate"><span class="pre">month_name</span></code></a>.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.15.</span></p>
</div>
</dd></dl>

<dl class="py data">
<dt class="sig sig-object py" id="calendar.standalone_month_abbr">
<span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">standalone_month_abbr</span></span><a class="headerlink" href="#calendar.standalone_month_abbr" title="Link to this definition"></a></dt>
<dd><p>A sequence that represents the abbreviated months of the year in the current
locale in the standalone form if the locale provides one. Else it is
equivalent to <a class="reference internal" href="#calendar.month_abbr" title="calendar.month_abbr"><code class="xref py py-data docutils literal notranslate"><span class="pre">month_abbr</span></code></a>.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.15.</span></p>
</div>
</dd></dl>

<dl class="py data">
<dt class="sig sig-object py" id="calendar.JANUARY">
<span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">JANUARY</span></span><a class="headerlink" href="#calendar.JANUARY" title="Link to this definition"></a></dt>
<dt class="sig sig-object py" id="calendar.FEBRUARY">
<span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">FEBRUARY</span></span><a class="headerlink" href="#calendar.FEBRUARY" title="Link to this definition"></a></dt>
<dt class="sig sig-object py" id="calendar.MARCH">
<span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">MARCH</span></span><a class="headerlink" href="#calendar.MARCH" title="Link to this definition"></a></dt>
<dt class="sig sig-object py" id="calendar.APRIL">
<span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">APRIL</span></span><a class="headerlink" href="#calendar.APRIL" title="Link to this definition"></a></dt>
<dt class="sig sig-object py" id="calendar.MAY">
<span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">MAY</span></span><a class="headerlink" href="#calendar.MAY" title="Link to this definition"></a></dt>
<dt class="sig sig-object py" id="calendar.JUNE">
<span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">JUNE</span></span><a class="headerlink" href="#calendar.JUNE" title="Link to this definition"></a></dt>
<dt class="sig sig-object py" id="calendar.JULY">
<span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">JULY</span></span><a class="headerlink" href="#calendar.JULY" title="Link to this definition"></a></dt>
<dt class="sig sig-object py" id="calendar.AUGUST">
<span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">AUGUST</span></span><a class="headerlink" href="#calendar.AUGUST" title="Link to this definition"></a></dt>
<dt class="sig sig-object py" id="calendar.SEPTEMBER">
<span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">SEPTEMBER</span></span><a class="headerlink" href="#calendar.SEPTEMBER" title="Link to this definition"></a></dt>
<dt class="sig sig-object py" id="calendar.OCTOBER">
<span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">OCTOBER</span></span><a class="headerlink" href="#calendar.OCTOBER" title="Link to this definition"></a></dt>
<dt class="sig sig-object py" id="calendar.NOVEMBER">
<span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">NOVEMBER</span></span><a class="headerlink" href="#calendar.NOVEMBER" title="Link to this definition"></a></dt>
<dt class="sig sig-object py" id="calendar.DECEMBER">
<span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">DECEMBER</span></span><a class="headerlink" href="#calendar.DECEMBER" title="Link to this definition"></a></dt>
<dd><p>Aliases for the months of the year,
where <code class="docutils literal notranslate"><span class="pre">JANUARY</span></code> is <code class="docutils literal notranslate"><span class="pre">1</span></code> and <code class="docutils literal notranslate"><span class="pre">DECEMBER</span></code> is <code class="docutils literal notranslate"><span class="pre">12</span></code>.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.12.</span></p>
</div>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="calendar.Month">
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">Month</span></span><a class="headerlink" href="#calendar.Month" title="Link to this definition"></a></dt>
<dd><p>Enumeration defining months of the year as integer constants.
The members of this enumeration are exported to the module scope as
<a class="reference internal" href="#calendar.JANUARY" title="calendar.JANUARY"><code class="xref py py-data docutils literal notranslate"><span class="pre">JANUARY</span></code></a> through <a class="reference internal" href="#calendar.DECEMBER" title="calendar.DECEMBER"><code class="xref py py-data docutils literal notranslate"><span class="pre">DECEMBER</span></code></a>.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.12.</span></p>
</div>
</dd></dl>

<p>The <code class="xref py py-mod docutils literal notranslate"><span class="pre">calendar</span></code> module defines the following exceptions:</p>
<dl class="py exception">
<dt class="sig sig-object py" id="calendar.IllegalMonthError">
<em class="property"><span class="k"><span class="pre">exception</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">IllegalMonthError</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">month</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.IllegalMonthError" title="Link to this definition"></a></dt>
<dd><p>A subclass of <a class="reference internal" href="exceptions.html#ValueError" title="ValueError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code></a>,
raised when the given month number is outside of the range 1-12 (inclusive).</p>
<dl class="py attribute">
<dt class="sig sig-object py" id="calendar.IllegalMonthError.month">
<span class="sig-name descname"><span class="pre">month</span></span><a class="headerlink" href="#calendar.IllegalMonthError.month" title="Link to this definition"></a></dt>
<dd><p>The invalid month number.</p>
</dd></dl>

</dd></dl>

<dl class="py exception">
<dt class="sig sig-object py" id="calendar.IllegalWeekdayError">
<em class="property"><span class="k"><span class="pre">exception</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">IllegalWeekdayError</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">weekday</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.IllegalWeekdayError" title="Link to this definition"></a></dt>
<dd><p>A subclass of <a class="reference internal" href="exceptions.html#ValueError" title="ValueError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code></a>,
raised when the given weekday number is outside of the range 0-6 (inclusive).</p>
<dl class="py attribute">
<dt class="sig sig-object py" id="calendar.IllegalWeekdayError.weekday">
<span class="sig-name descname"><span class="pre">weekday</span></span><a class="headerlink" href="#calendar.IllegalWeekdayError.weekday" title="Link to this definition"></a></dt>
<dd><p>The invalid weekday number.</p>
</dd></dl>

</dd></dl>

<div class="admonition seealso">
<p class="admonition-title">See also</p>
<dl class="simple">
<dt>Module <a class="reference internal" href="datetime.html#module-datetime" title="datetime: Basic date and time types."><code class="xref py py-mod docutils literal notranslate"><span class="pre">datetime</span></code></a></dt><dd><p>Object-oriented interface to dates and times with similar functionality to the
<a class="reference internal" href="time.html#module-time" title="time: Time access and conversions."><code class="xref py py-mod docutils literal notranslate"><span class="pre">time</span></code></a> module.</p>
</dd>
<dt>Module <a class="reference internal" href="time.html#module-time" title="time: Time access and conversions."><code class="xref py py-mod docutils literal notranslate"><span class="pre">time</span></code></a></dt><dd><p>Low-level time related functions.</p>
</dd>
</dl>
</div>
<section id="command-line-usage">
<span id="calendar-cli"></span><h2>Command-line usage<a class="headerlink" href="#command-line-usage" title="Link to this heading"></a></h2>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 2.5.</span></p>
</div>
<p>The <code class="xref py py-mod docutils literal notranslate"><span class="pre">calendar</span></code> module can be executed as a script from the command line
to interactively print a calendar.</p>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>python<span class="w"> </span>-m<span class="w"> </span>calendar<span class="w"> </span><span class="o">[</span>-h<span class="o">]</span><span class="w"> </span><span class="o">[</span>-L<span class="w"> </span>LOCALE<span class="o">]</span><span class="w"> </span><span class="o">[</span>-e<span class="w"> </span>ENCODING<span class="o">]</span><span class="w"> </span><span class="o">[</span>-t<span class="w"> </span><span class="o">{</span>text,html<span class="o">}]</span>
<span class="w">                   </span><span class="o">[</span>-w<span class="w"> </span>WIDTH<span class="o">]</span><span class="w"> </span><span class="o">[</span>-l<span class="w"> </span>LINES<span class="o">]</span><span class="w"> </span><span class="o">[</span>-s<span class="w"> </span>SPACING<span class="o">]</span><span class="w"> </span><span class="o">[</span>-m<span class="w"> </span>MONTHS<span class="o">]</span><span class="w"> </span><span class="o">[</span>-c<span class="w"> </span>CSS<span class="o">]</span>
<span class="w">                   </span><span class="o">[</span>-f<span class="w"> </span>FIRST_WEEKDAY<span class="o">]</span><span class="w"> </span><span class="o">[</span>year<span class="o">]</span><span class="w"> </span><span class="o">[</span>month<span class="o">]</span>
</pre></div>
</div>
<p>For example, to print a calendar for the year 2000:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>python<span class="w"> </span>-m<span class="w"> </span>calendar<span class="w"> </span><span class="m">2000</span>
<span class="go">                                  2000</span>

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

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

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

<span class="go">      October                   November                  December</span>
<span class="go">Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su</span>
<span class="go">                   1             1  2  3  4  5                   1  2  3</span>
<span class="go"> 2  3  4  5  6  7  8       6  7  8  9 10 11 12       4  5  6  7  8  9 10</span>
<span class="go"> 9 10 11 12 13 14 15      13 14 15 16 17 18 19      11 12 13 14 15 16 17</span>
<span class="go">16 17 18 19 20 21 22      20 21 22 23 24 25 26      18 19 20 21 22 23 24</span>
<span class="go">23 24 25 26 27 28 29      27 28 29 30               25 26 27 28 29 30 31</span>
<span class="go">30 31</span>
</pre></div>
</div>
<p>The following options are accepted:</p>
<dl class="std option">
<dt class="sig sig-object std" id="cmdoption-calendar-help">
<span id="cmdoption-calendar-h"></span><span class="sig-name descname"><span class="pre">--help</span></span><span class="sig-prename descclassname"></span><span class="sig-prename descclassname"><span class="pre">,</span> </span><span class="sig-name descname"><span class="pre">-h</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-calendar-help" title="Link to this definition"></a></dt>
<dd><p>Show the help message and exit.</p>
</dd></dl>

<dl class="std option">
<dt class="sig sig-object std" id="cmdoption-calendar-locale">
<span id="cmdoption-calendar-L"></span><span class="sig-name descname"><span class="pre">--locale</span></span><span class="sig-prename descclassname"> <span class="pre">LOCALE</span></span><span class="sig-prename descclassname"><span class="pre">,</span> </span><span class="sig-name descname"><span class="pre">-L</span></span><span class="sig-prename descclassname"> <span class="pre">LOCALE</span></span><a class="headerlink" href="#cmdoption-calendar-locale" title="Link to this definition"></a></dt>
<dd><p>The locale to use for month and weekday names.
Defaults to English.</p>
</dd></dl>

<dl class="std option">
<dt class="sig sig-object std" id="cmdoption-calendar-encoding">
<span id="cmdoption-calendar-e"></span><span class="sig-name descname"><span class="pre">--encoding</span></span><span class="sig-prename descclassname"> <span class="pre">ENCODING</span></span><span class="sig-prename descclassname"><span class="pre">,</span> </span><span class="sig-name descname"><span class="pre">-e</span></span><span class="sig-prename descclassname"> <span class="pre">ENCODING</span></span><a class="headerlink" href="#cmdoption-calendar-encoding" title="Link to this definition"></a></dt>
<dd><p>The encoding to use for output.
<a class="reference internal" href="#cmdoption-calendar-encoding"><code class="xref std std-option docutils literal notranslate"><span class="pre">--encoding</span></code></a> is required if <a class="reference internal" href="#cmdoption-calendar-locale"><code class="xref std std-option docutils literal notranslate"><span class="pre">--locale</span></code></a> is set.</p>
</dd></dl>

<dl class="std option">
<dt class="sig sig-object std" id="cmdoption-calendar-type">
<span id="cmdoption-calendar-t"></span><span class="sig-name descname"><span class="pre">--type</span></span><span class="sig-prename descclassname"> <span class="pre">{text,html}</span></span><span class="sig-prename descclassname"><span class="pre">,</span> </span><span class="sig-name descname"><span class="pre">-t</span></span><span class="sig-prename descclassname"> <span class="pre">{text,html}</span></span><a class="headerlink" href="#cmdoption-calendar-type" title="Link to this definition"></a></dt>
<dd><p>Print the calendar to the terminal as text,
or as an HTML document.</p>
</dd></dl>

<dl class="std option">
<dt class="sig sig-object std" id="cmdoption-calendar-first-weekday">
<span id="cmdoption-calendar-f"></span><span class="sig-name descname"><span class="pre">--first-weekday</span></span><span class="sig-prename descclassname"> <span class="pre">FIRST_WEEKDAY</span></span><span class="sig-prename descclassname"><span class="pre">,</span> </span><span class="sig-name descname"><span class="pre">-f</span></span><span class="sig-prename descclassname"> <span class="pre">FIRST_WEEKDAY</span></span><a class="headerlink" href="#cmdoption-calendar-first-weekday" title="Link to this definition"></a></dt>
<dd><p>The weekday to start each week.
Must be a number between 0 (Monday) and 6 (Sunday).
Defaults to 0.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.13.</span></p>
</div>
</dd></dl>

<dl class="std option">
<dt class="sig sig-object std" id="cmdoption-calendar-arg-year">
<span class="sig-name descname"><span class="pre">year</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-calendar-arg-year" title="Link to this definition"></a></dt>
<dd><p>The year to print the calendar for.
Defaults to the current year.</p>
</dd></dl>

<dl class="std option">
<dt class="sig sig-object std" id="cmdoption-calendar-arg-month">
<span class="sig-name descname"><span class="pre">month</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-calendar-arg-month" title="Link to this definition"></a></dt>
<dd><p>The month of the specified <a class="reference internal" href="#cmdoption-calendar-arg-year"><code class="xref std std-option docutils literal notranslate"><span class="pre">year</span></code></a> to print the calendar for.
Must be a number between 1 and 12.
Defaults to printing a calendar for the full year.</p>
</dd></dl>

<p><em>Text-mode options:</em></p>
<dl class="std option">
<dt class="sig sig-object std" id="cmdoption-calendar-width">
<span id="cmdoption-calendar-w"></span><span class="sig-name descname"><span class="pre">--width</span></span><span class="sig-prename descclassname"> <span class="pre">WIDTH</span></span><span class="sig-prename descclassname"><span class="pre">,</span> </span><span class="sig-name descname"><span class="pre">-w</span></span><span class="sig-prename descclassname"> <span class="pre">WIDTH</span></span><a class="headerlink" href="#cmdoption-calendar-width" title="Link to this definition"></a></dt>
<dd><p>The width of the date column in terminal columns.
The date is printed centred in the column.
Any value lower than 2 is ignored.
Defaults to 2.</p>
</dd></dl>

<dl class="std option">
<dt class="sig sig-object std" id="cmdoption-calendar-lines">
<span id="cmdoption-calendar-l"></span><span class="sig-name descname"><span class="pre">--lines</span></span><span class="sig-prename descclassname"> <span class="pre">LINES</span></span><span class="sig-prename descclassname"><span class="pre">,</span> </span><span class="sig-name descname"><span class="pre">-l</span></span><span class="sig-prename descclassname"> <span class="pre">LINES</span></span><a class="headerlink" href="#cmdoption-calendar-lines" title="Link to this definition"></a></dt>
<dd><p>The number of lines for each week in terminal rows.
The date is printed top-aligned.
Any value lower than 1 is ignored.
Defaults to 1.</p>
</dd></dl>

<dl class="std option">
<dt class="sig sig-object std" id="cmdoption-calendar-spacing">
<span id="cmdoption-calendar-s"></span><span class="sig-name descname"><span class="pre">--spacing</span></span><span class="sig-prename descclassname"> <span class="pre">SPACING</span></span><span class="sig-prename descclassname"><span class="pre">,</span> </span><span class="sig-name descname"><span class="pre">-s</span></span><span class="sig-prename descclassname"> <span class="pre">SPACING</span></span><a class="headerlink" href="#cmdoption-calendar-spacing" title="Link to this definition"></a></dt>
<dd><p>The space between months in columns.
Any value lower than 2 is ignored.
Defaults to 6.</p>
</dd></dl>

<dl class="std option">
<dt class="sig sig-object std" id="cmdoption-calendar-months">
<span id="cmdoption-calendar-m"></span><span class="sig-name descname"><span class="pre">--months</span></span><span class="sig-prename descclassname"> <span class="pre">MONTHS</span></span><span class="sig-prename descclassname"><span class="pre">,</span> </span><span class="sig-name descname"><span class="pre">-m</span></span><span class="sig-prename descclassname"> <span class="pre">MONTHS</span></span><a class="headerlink" href="#cmdoption-calendar-months" title="Link to this definition"></a></dt>
<dd><p>The number of months printed per row.
Defaults to 3.</p>
</dd></dl>

<div class="versionchanged">
<p><span class="versionmodified changed">Changed in version 3.14: </span>By default, today’s date is highlighted in color and can be
<a class="reference internal" href="../using/cmdline.html#using-on-controlling-color"><span class="std std-ref">controlled using environment variables</span></a>.</p>
</div>
<p><em>HTML-mode options:</em></p>
<dl class="std option">
<dt class="sig sig-object std" id="cmdoption-calendar-css">
<span id="cmdoption-calendar-c"></span><span class="sig-name descname"><span class="pre">--css</span></span><span class="sig-prename descclassname"> <span class="pre">CSS</span></span><span class="sig-prename descclassname"><span class="pre">,</span> </span><span class="sig-name descname"><span class="pre">-c</span></span><span class="sig-prename descclassname"> <span class="pre">CSS</span></span><a class="headerlink" href="#cmdoption-calendar-css" title="Link to this definition"></a></dt>
<dd><p>The path of a CSS stylesheet to use for the calendar.
This must either be relative to the generated HTML,
or an absolute HTTP or <code class="docutils literal notranslate"><span class="pre">file:///</span></code> URL.</p>
</dd></dl>

</section>
</section>


            <div class="clearer"></div>
          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="Main">
        <div class="sphinxsidebarwrapper">
  <div>
    <h3><a href="../contents.html">Table of Contents</a></h3>
    <ul>
<li><a class="reference internal" href="#"><code class="xref py py-mod docutils literal notranslate"><span class="pre">calendar</span></code> — General calendar-related functions</a><ul>
<li><a class="reference internal" href="#command-line-usage">Command-line usage</a></li>
</ul>
</li>
</ul>

  </div>
  <div>
    <h4>Previous topic</h4>
    <p class="topless"><a href="zoneinfo.html"
                          title="previous chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">zoneinfo</span></code> — IANA time zone support</a></p>
  </div>
  <div>
    <h4>Next topic</h4>
    <p class="topless"><a href="collections.html"
                          title="next chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">collections</span></code> — Container datatypes</a></p>
  </div>
  <script>
    document.addEventListener('DOMContentLoaded', () => {
        const title = document.querySelector('meta[property="og:title"]').content;
        const elements = document.querySelectorAll('.improvepage');
        const pageurl = window.location.href.split('?')[0];
        elements.forEach(element => {
            const url = new URL(element.href.split('?')[0].replace("-nojs", ""));
            url.searchParams.set('pagetitle', title);
            url.searchParams.set('pageurl', pageurl);
            url.searchParams.set('pagesource', "library/calendar.rst");
            element.href = url.toString();
        });
    });
  </script>
  <div role="note" aria-label="source link">
    <h3>This page</h3>
    <ul class="this-page-menu">
      <li><a href="../bugs.html">Report a bug</a></li>
      <li><a class="improvepage" href="../improve-page-nojs.html">Improve this page</a></li>
      <li>
        <a href="https://github.com/python/cpython/blob/main/Doc/library/calendar.rst?plain=1"
            rel="nofollow">Show source
        </a>
      </li>
      
    </ul>
  </div>
        </div>
<div id="sidebarbutton" title="Collapse sidebar">
<span>«</span>
</div>

      </div>
      <div class="clearer"></div>
    </div>  
    <div class="related" role="navigation" aria-label="Related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="collections.html" title="collections — Container datatypes"
             >next</a> |</li>
        <li class="right" >
          <a href="zoneinfo.html" title="zoneinfo — IANA time zone support"
             >previous</a> |</li>

          <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"></li>
          <li><a href="https://www.python.org/">Python</a> &#187;</li>
          <li class="switchers">
            <div class="language_switcher_placeholder"></div>
            <div class="version_switcher_placeholder"></div>
          </li>
          <li>
              
          </li>
    <li id="cpython-language-and-version">
      <a href="../index.html">3.15.0a6 Documentation</a> &#187;
    </li>

          <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="datatypes.html" >Data Types</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href=""><code class="xref py py-mod docutils literal notranslate"><span class="pre">calendar</span></code> — General calendar-related functions</a></li>
                <li class="right">
                    

    <div class="inline-search" role="search">
        <form class="inline-search" action="../search.html" method="get">
          <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box">
          <input type="submit" value="Go">
        </form>
    </div>
                     |
                </li>
            <li class="right">
<label class="theme-selector-label">
    Theme
    <select class="theme-selector" oninput="activateTheme(this.value)">
        <option value="auto" selected>Auto</option>
        <option value="light">Light</option>
        <option value="dark">Dark</option>
    </select>
</label> |</li>
            
      </ul>
    </div>  
    <div class="footer">
    &copy; <a href="../copyright.html">Copyright</a> 2001 Python Software Foundation.
    <br>
    This page is licensed under the Python Software Foundation License Version 2.
    <br>
    Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.
    <br>
    
      See <a href="/license.html">History and License</a> for more information.<br>
    
    
    <br>

    The Python Software Foundation is a non-profit corporation.
<a href="https://www.python.org/psf/donations/">Please donate.</a>
<br>
    <br>
      Last updated on Mar 10, 2026 (08:58 UTC).
    
      <a href="/bugs.html">Found a bug</a>?
    
    <br>

    Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 8.2.3.
    </div>

  </body>
</html>