Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Doc/library/calendar.rst
Original file line number Diff line number Diff line change
Expand Up @@ -586,10 +586,16 @@ The following options are accepted:
or as an HTML document.


.. option:: --first-weekday WEEKDAY, -f WEEKDAY

The weekday to start each week.
Must be a number between 0 (Monday) and 6 (Sunday).
Defaults to 0.


.. option:: year

The year to print the calendar for.
Must be a number between 1 and 9999.
Defaults to the current year.


Expand Down
7 changes: 7 additions & 0 deletions Lib/calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,11 @@ def main(args=None):
choices=("text", "html"),
help="output type (text or html)"
)
parser.add_argument(
"-f", "--first-weekday",
type=int, default=0,
help="weekday (0 is Monday, 6 is Sunday) to start each week (default 0)"
)
parser.add_argument(
"year",
nargs='?', type=int,
Expand Down Expand Up @@ -761,6 +766,7 @@ def main(args=None):
cal = LocaleHTMLCalendar(locale=locale)
else:
cal = HTMLCalendar()
cal.setfirstweekday(options.first_weekday)
encoding = options.encoding
if encoding is None:
encoding = sys.getdefaultencoding()
Expand All @@ -775,6 +781,7 @@ def main(args=None):
cal = LocaleTextCalendar(locale=locale)
else:
cal = TextCalendar()
cal.setfirstweekday(options.first_weekday)
optdict = dict(w=options.width, l=options.lines)
if options.month is None:
optdict["c"] = options.spacing
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Add option to calendar module CLI to specify the weekday to start each week.
Patch by Steven Ward.