Skip to content

Commit cab5c5c

Browse files
committed
Issue #8899: time.struct_time now has class and atribute docstrings.
1 parent 77843c6 commit cab5c5c

3 files changed

Lines changed: 27 additions & 18 deletions

File tree

Doc/library/time.rst

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,25 +87,26 @@ An explanation of some terminology and conventions is in order.
8787
+=======+===================+=================================+
8888
| 0 | :attr:`tm_year` | (for example, 1993) |
8989
+-------+-------------------+---------------------------------+
90-
| 1 | :attr:`tm_mon` | range [1,12] |
90+
| 1 | :attr:`tm_mon` | range [1, 12] |
9191
+-------+-------------------+---------------------------------+
92-
| 2 | :attr:`tm_mday` | range [1,31] |
92+
| 2 | :attr:`tm_mday` | range [1, 31] |
9393
+-------+-------------------+---------------------------------+
94-
| 3 | :attr:`tm_hour` | range [0,23] |
94+
| 3 | :attr:`tm_hour` | range [0, 23] |
9595
+-------+-------------------+---------------------------------+
96-
| 4 | :attr:`tm_min` | range [0,59] |
96+
| 4 | :attr:`tm_min` | range [0, 59] |
9797
+-------+-------------------+---------------------------------+
98-
| 5 | :attr:`tm_sec` | range [0,61]; see **(1)** in |
98+
| 5 | :attr:`tm_sec` | range [0, 61]; see **(1)** in |
9999
| | | :func:`strftime` description |
100100
+-------+-------------------+---------------------------------+
101-
| 6 | :attr:`tm_wday` | range [0,6], Monday is 0 |
101+
| 6 | :attr:`tm_wday` | range [0, 6], Monday is 0 |
102102
+-------+-------------------+---------------------------------+
103-
| 7 | :attr:`tm_yday` | range [1,366] |
103+
| 7 | :attr:`tm_yday` | range [1, 366] |
104104
+-------+-------------------+---------------------------------+
105105
| 8 | :attr:`tm_isdst` | 0, 1 or -1; see below |
106106
+-------+-------------------+---------------------------------+
107107

108-
Note that unlike the C structure, the month value is a range of 1-12, not 0-11.
108+
Note that unlike the C structure, the month value is a range of [1, 12],
109+
not [0, 11].
109110
A year value will be handled as described under "Year 2000 (Y2K) issues" above.
110111
A ``-1`` argument as the daylight savings flag, passed to :func:`mktime` will
111112
usually result in the correct daylight savings state to be filled in.

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ C-API
5252
Library
5353
-------
5454

55+
- Issue #8899: time.struct_time now has class and atribute docstrings.
56+
5557
- Issue #4487: email now accepts as charset aliases all codec aliases
5658
accepted by the codecs module.
5759

Modules/timemodule.c

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -216,21 +216,27 @@ Delay execution for a given number of seconds. The argument may be\n\
216216
a floating point number for subsecond precision.");
217217

218218
static PyStructSequence_Field struct_time_type_fields[] = {
219-
{"tm_year", NULL},
220-
{"tm_mon", NULL},
221-
{"tm_mday", NULL},
222-
{"tm_hour", NULL},
223-
{"tm_min", NULL},
224-
{"tm_sec", NULL},
225-
{"tm_wday", NULL},
226-
{"tm_yday", NULL},
227-
{"tm_isdst", NULL},
219+
{"tm_year", "year, for example, 1993"},
220+
{"tm_mon", "month of year, range [1, 12]"},
221+
{"tm_mday", "day of month, range [1, 31]"},
222+
{"tm_hour", "hours, range [0, 23]"},
223+
{"tm_min", "minutes, range [0, 59]"},
224+
{"tm_sec", "seconds, range [0, 61])"},
225+
{"tm_wday", "day of week, range [0, 6], Monday is 0"},
226+
{"tm_yday", "day of year, range [1, 366]"},
227+
{"tm_isdst", "1 if summer time is in effect, 0 if not, and -1 if unknown"},
228228
{0}
229229
};
230230

231231
static PyStructSequence_Desc struct_time_type_desc = {
232232
"time.struct_time",
233-
NULL,
233+
"The time value as returned by gmtime(), localtime(), and strptime(), and\n"
234+
" accepted by asctime(), mktime() and strftime(). May be considered as a\n"
235+
" sequence of 9 integers.\n\n"
236+
" Note that several fields' values are not the same as those defined by\n"
237+
" the C language standard for struct tm. For example, the value of the\n"
238+
" field tm_year is the actual year, not year - 1900. See individual\n"
239+
" fields' descriptions for details.",
234240
struct_time_type_fields,
235241
9,
236242
};

0 commit comments

Comments
 (0)