@@ -38,13 +38,33 @@ interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is
3838 itself. This is the job of subclasses.
3939
4040
41- :class: `Calendar ` instances have the following methods:
41+ :class: `Calendar ` instances have the following methods and attributes:
42+
43+ .. attribute :: firstweekday
44+
45+ The first weekday as an integer (0--6).
46+
47+ This property can also be set and read using
48+ :meth: `~Calendar.setfirstweekday ` and
49+ :meth: `~Calendar.getfirstweekday ` respectively.
50+
51+ .. method :: getfirstweekday()
52+
53+ Return an :class: `int ` for the current first weekday (0--6).
54+
55+ Identical to reading the :attr: `~Calendar.firstweekday ` property.
56+
57+ .. method :: setfirstweekday(firstweekday)
58+
59+ Set the first weekday to *firstweekday *, passed as an :class: `int ` (0--6)
60+
61+ Identical to setting the :attr: `~Calendar.firstweekday ` property.
4262
4363 .. method :: iterweekdays()
4464
4565 Return an iterator for the week day numbers that will be used for one
4666 week. The first value from the iterator will be the same as the value of
47- the :attr: `firstweekday ` property.
67+ the :attr: `~Calendar. firstweekday ` property.
4868
4969
5070 .. method :: itermonthdates(year, month)
@@ -138,29 +158,69 @@ interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is
138158
139159 :class: `TextCalendar ` instances have the following methods:
140160
141- .. method :: formatweek(theweek, w=0)
161+
162+ .. method :: formatday(theday, weekday, width)
163+
164+ Return a string representing a single day formatted with the given *width *.
165+ If *theday * is ``0 ``, return a string of spaces of
166+ the specified width, representing an empty day. The *weekday * parameter
167+ is unused.
168+
169+ .. method :: formatweek(theweek, w=0, highlight_day=None)
142170
143171 Return a single week in a string with no newline. If *w * is provided, it
144172 specifies the width of the date columns, which are centered. Depends
145173 on the first weekday as specified in the constructor or set by the
146174 :meth: `setfirstweekday ` method.
147175
176+ .. versionchanged :: next
177+ If *highlight_day * is given, this date is highlighted in color.
178+ This can be :ref: `controlled using environment variables
179+ <using-on-controlling-color>`.
148180
149- .. method :: formatmonth(theyear, themonth, w=0, l=0)
181+
182+ .. method :: formatweekday(weekday, width)
183+
184+ Return a string representing the name of a single weekday formatted to
185+ the specified *width *. The *weekday * parameter is an integer representing
186+ the day of the week, where ``0 `` is Monday and ``6 `` is Sunday.
187+
188+
189+ .. method :: formatweekheader(width)
190+
191+ Return a string containing the header row of weekday names, formatted
192+ with the given *width * for each column. The names depend on the locale
193+ settings and are padded to the specified width.
194+
195+
196+ .. method :: formatmonth(theyear, themonth, w=0, l=0, highlight_day=None)
150197
151198 Return a month's calendar in a multi-line string. If *w * is provided, it
152199 specifies the width of the date columns, which are centered. If *l * is
153200 given, it specifies the number of lines that each week will use. Depends
154201 on the first weekday as specified in the constructor or set by the
155202 :meth: `setfirstweekday ` method.
156203
204+ .. versionchanged :: next
205+ If *highlight_day * is given, this date is highlighted in color.
206+ This can be :ref: `controlled using environment variables
207+ <using-on-controlling-color>`.
208+
209+
210+ .. method :: formatmonthname(theyear, themonth, width=0, withyear=True)
211+
212+ Return a string representing the month's name centered within the
213+ specified *width *. If *withyear * is ``True ``, include the year in the
214+ output. The *theyear * and *themonth * parameters specify the year
215+ and month for the name to be formatted respectively.
216+
157217
158218 .. method :: prmonth(theyear, themonth, w=0, l=0)
159219
160220 Print a month's calendar as returned by :meth: `formatmonth `.
161221
162222
163- .. method :: formatyear(theyear, w=2, l=1, c=6, m=3)
223+ .. method :: formatyear(theyear, w=2, l=1, c=6, m=3, highlight_day=None )
164224
165225 Return a *m *-column calendar for an entire year as a multi-line string.
166226 Optional parameters *w *, *l *, and *c * are for date column width, lines per
@@ -169,6 +229,11 @@ interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is
169229 :meth: `setfirstweekday ` method. The earliest year for which a calendar
170230 can be generated is platform-dependent.
171231
232+ .. versionchanged :: next
233+ If *highlight_day * is given, this date is highlighted in color.
234+ This can be :ref: `controlled using environment variables
235+ <using-on-controlling-color>`.
236+
172237
173238 .. method :: pryear(theyear, w=2, l=1, c=6, m=3)
174239
@@ -445,7 +510,7 @@ The :mod:`calendar` module exports the following data attributes:
445510
446511 A sequence that represents the months of the year in the current locale. This
447512 follows normal convention of January being month number 1, so it has a length of
448- 13 and ``month_name[0] `` is the empty string.
513+ 13 and ``month_name[0] `` is the empty string.
449514
450515 >>> import calendar
451516 >>> list (calendar.month_name)
@@ -524,7 +589,7 @@ The :mod:`calendar` module defines the following exceptions:
524589
525590.. _calendar-cli :
526591
527- Command-Line Usage
592+ Command-line usage
528593------------------
529594
530595.. versionadded :: 2.5
@@ -662,6 +727,9 @@ The following options are accepted:
662727 The number of months printed per row.
663728 Defaults to 3.
664729
730+ .. versionchanged :: next
731+ By default, today's date is highlighted in color and can be
732+ :ref: `controlled using environment variables <using-on-controlling-color >`.
665733
666734*HTML-mode options: *
667735
0 commit comments