gh-112240: Add option to calendar module CLI to specify the weekday to start each week (GH-112241)
This commit is contained in:
parent
39c766b579
commit
2c089b09ac
@ -586,10 +586,16 @@ The following options are accepted:
|
|||||||
or as an HTML document.
|
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
|
.. option:: year
|
||||||
|
|
||||||
The year to print the calendar for.
|
The year to print the calendar for.
|
||||||
Must be a number between 1 and 9999.
|
|
||||||
Defaults to the current year.
|
Defaults to the current year.
|
||||||
|
|
||||||
|
|
||||||
|
@ -734,6 +734,11 @@ def main(args=None):
|
|||||||
choices=("text", "html"),
|
choices=("text", "html"),
|
||||||
help="output type (text or 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(
|
parser.add_argument(
|
||||||
"year",
|
"year",
|
||||||
nargs='?', type=int,
|
nargs='?', type=int,
|
||||||
@ -761,6 +766,7 @@ def main(args=None):
|
|||||||
cal = LocaleHTMLCalendar(locale=locale)
|
cal = LocaleHTMLCalendar(locale=locale)
|
||||||
else:
|
else:
|
||||||
cal = HTMLCalendar()
|
cal = HTMLCalendar()
|
||||||
|
cal.setfirstweekday(options.first_weekday)
|
||||||
encoding = options.encoding
|
encoding = options.encoding
|
||||||
if encoding is None:
|
if encoding is None:
|
||||||
encoding = sys.getdefaultencoding()
|
encoding = sys.getdefaultencoding()
|
||||||
@ -775,6 +781,7 @@ def main(args=None):
|
|||||||
cal = LocaleTextCalendar(locale=locale)
|
cal = LocaleTextCalendar(locale=locale)
|
||||||
else:
|
else:
|
||||||
cal = TextCalendar()
|
cal = TextCalendar()
|
||||||
|
cal.setfirstweekday(options.first_weekday)
|
||||||
optdict = dict(w=options.width, l=options.lines)
|
optdict = dict(w=options.width, l=options.lines)
|
||||||
if options.month is None:
|
if options.month is None:
|
||||||
optdict["c"] = options.spacing
|
optdict["c"] = options.spacing
|
||||||
|
@ -0,0 +1,2 @@
|
|||||||
|
Add option to calendar module CLI to specify the weekday to start each week.
|
||||||
|
Patch by Steven Ward.
|
Loading…
x
Reference in New Issue
Block a user