Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b67878a

Browse files
committed
#7790: move table of struct_time members to the actual description of struct_time.
1 parent 39cadc3 commit b67878a

1 file changed

Lines changed: 50 additions & 44 deletions

File tree

Doc/library/time.rst

Lines changed: 50 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,23 @@ semantics of these functions varies among platforms.
1616

1717
An explanation of some terminology and conventions is in order.
1818

19-
.. index:: single: epoch
19+
.. index:: single: epoch
2020

2121
* The :dfn:`epoch` is the point where the time starts. On January 1st of that
2222
year, at 0 hours, the "time since the epoch" is zero. For Unix, the epoch is
2323
1970. To find out what the epoch is, look at ``gmtime(0)``.
2424

25-
.. index:: single: Year 2038
25+
.. index:: single: Year 2038
2626

2727
* The functions in this module do not handle dates and times before the epoch or
2828
far in the future. The cut-off point in the future is determined by the C
2929
library; for Unix, it is typically in 2038.
3030

31-
.. index::
32-
single: Year 2000
33-
single: Y2K
31+
.. index::
32+
single: Year 2000
33+
single: Y2K
34+
35+
.. _time-y2kissues:
3436

3537
* **Year 2000 (Y2K) issues**: Python depends on the platform's C library, which
3638
generally doesn't have year 2000 issues, since all dates and times are
@@ -47,16 +49,16 @@ An explanation of some terminology and conventions is in order.
4749
Note that this is new as of Python 1.5.2(a2); earlier versions, up to Python
4850
1.5.1 and 1.5.2a1, would add 1900 to year values below 1900.
4951

50-
.. index::
51-
single: UTC
52-
single: Coordinated Universal Time
53-
single: Greenwich Mean Time
52+
.. index::
53+
single: UTC
54+
single: Coordinated Universal Time
55+
single: Greenwich Mean Time
5456

5557
* UTC is Coordinated Universal Time (formerly known as Greenwich Mean Time, or
5658
GMT). The acronym UTC is not a mistake but a compromise between English and
5759
French.
5860

59-
.. index:: single: Daylight Saving Time
61+
.. index:: single: Daylight Saving Time
6062

6163
* DST is Daylight Saving Time, an adjustment of the timezone by (usually) one
6264
hour during part of the year. DST rules are magic (determined by local law) and
@@ -81,38 +83,7 @@ An explanation of some terminology and conventions is in order.
8183
:func:`gmtime`, :func:`localtime`, and :func:`strptime` also offer attribute
8284
names for individual fields.
8385

84-
+-------+-------------------+---------------------------------+
85-
| Index | Attribute | Values |
86-
+=======+===================+=================================+
87-
| 0 | :attr:`tm_year` | (for example, 1993) |
88-
+-------+-------------------+---------------------------------+
89-
| 1 | :attr:`tm_mon` | range [1, 12] |
90-
+-------+-------------------+---------------------------------+
91-
| 2 | :attr:`tm_mday` | range [1, 31] |
92-
+-------+-------------------+---------------------------------+
93-
| 3 | :attr:`tm_hour` | range [0, 23] |
94-
+-------+-------------------+---------------------------------+
95-
| 4 | :attr:`tm_min` | range [0, 59] |
96-
+-------+-------------------+---------------------------------+
97-
| 5 | :attr:`tm_sec` | range [0, 61]; see **(1)** in |
98-
| | | :func:`strftime` description |
99-
+-------+-------------------+---------------------------------+
100-
| 6 | :attr:`tm_wday` | range [0, 6], Monday is 0 |
101-
+-------+-------------------+---------------------------------+
102-
| 7 | :attr:`tm_yday` | range [1, 366] |
103-
+-------+-------------------+---------------------------------+
104-
| 8 | :attr:`tm_isdst` | 0, 1 or -1; see below |
105-
+-------+-------------------+---------------------------------+
106-
107-
Note that unlike the C structure, the month value is a range of [1, 12],
108-
not [0, 11].
109-
A year value will be handled as described under "Year 2000 (Y2K) issues" above.
110-
A ``-1`` argument as the daylight savings flag, passed to :func:`mktime` will
111-
usually result in the correct daylight savings state to be filled in.
112-
113-
When a tuple with an incorrect length is passed to a function expecting a
114-
:class:`struct_time`, or having elements of the wrong type, a :exc:`TypeError`
115-
is raised.
86+
See :class:`struct_time` for a description of these objects.
11687

11788
* Use the following functions to convert between time representations:
11889

@@ -389,10 +360,45 @@ The module defines the following functions and data items:
389360
documented as supported.
390361

391362

392-
.. data:: struct_time
363+
.. class:: struct_time
393364

394365
The type of the time value sequence returned by :func:`gmtime`,
395-
:func:`localtime`, and :func:`strptime`.
366+
:func:`localtime`, and :func:`strptime`. It is an object with a :term:`named
367+
tuple` interface: values can be accessed by index and by attribute name. The
368+
following values are present:
369+
370+
+-------+-------------------+---------------------------------+
371+
| Index | Attribute | Values |
372+
+=======+===================+=================================+
373+
| 0 | :attr:`tm_year` | (for example, 1993) |
374+
+-------+-------------------+---------------------------------+
375+
| 1 | :attr:`tm_mon` | range [1, 12] |
376+
+-------+-------------------+---------------------------------+
377+
| 2 | :attr:`tm_mday` | range [1, 31] |
378+
+-------+-------------------+---------------------------------+
379+
| 3 | :attr:`tm_hour` | range [0, 23] |
380+
+-------+-------------------+---------------------------------+
381+
| 4 | :attr:`tm_min` | range [0, 59] |
382+
+-------+-------------------+---------------------------------+
383+
| 5 | :attr:`tm_sec` | range [0, 61]; see **(1)** in |
384+
| | | :func:`strftime` description |
385+
+-------+-------------------+---------------------------------+
386+
| 6 | :attr:`tm_wday` | range [0, 6], Monday is 0 |
387+
+-------+-------------------+---------------------------------+
388+
| 7 | :attr:`tm_yday` | range [1, 366] |
389+
+-------+-------------------+---------------------------------+
390+
| 8 | :attr:`tm_isdst` | 0, 1 or -1; see below |
391+
+-------+-------------------+---------------------------------+
392+
393+
Note that unlike the C structure, the month value is a range of [1, 12], not
394+
[0, 11]. A year value will be handled as described under :ref:`Year 2000
395+
(Y2K) issues <time-y2kissues>` above. A ``-1`` argument as the daylight
396+
savings flag, passed to :func:`mktime` will usually result in the correct
397+
daylight savings state to be filled in.
398+
399+
When a tuple with an incorrect length is passed to a function expecting a
400+
:class:`struct_time`, or having elements of the wrong type, a
401+
:exc:`TypeError` is raised.
396402

397403

398404
.. function:: time()

0 commit comments

Comments
 (0)