#7790: move table of struct_time members to the actual description of struct_time.

This commit is contained in:
Georg Brandl 2010-10-15 17:01:15 +00:00
parent 39cadc3ffe
commit b67878a522

View file

@ -32,6 +32,8 @@ An explanation of some terminology and conventions is in order.
single: Year 2000 single: Year 2000
single: Y2K single: Y2K
.. _time-y2kissues:
* **Year 2000 (Y2K) issues**: Python depends on the platform's C library, which * **Year 2000 (Y2K) issues**: Python depends on the platform's C library, which
generally doesn't have year 2000 issues, since all dates and times are generally doesn't have year 2000 issues, since all dates and times are
represented internally as seconds since the epoch. Functions accepting a represented internally as seconds since the epoch. Functions accepting a
@ -81,38 +83,7 @@ An explanation of some terminology and conventions is in order.
:func:`gmtime`, :func:`localtime`, and :func:`strptime` also offer attribute :func:`gmtime`, :func:`localtime`, and :func:`strptime` also offer attribute
names for individual fields. names for individual fields.
+-------+-------------------+---------------------------------+ See :class:`struct_time` for a description of these objects.
| Index | Attribute | Values |
+=======+===================+=================================+
| 0 | :attr:`tm_year` | (for example, 1993) |
+-------+-------------------+---------------------------------+
| 1 | :attr:`tm_mon` | range [1, 12] |
+-------+-------------------+---------------------------------+
| 2 | :attr:`tm_mday` | range [1, 31] |
+-------+-------------------+---------------------------------+
| 3 | :attr:`tm_hour` | range [0, 23] |
+-------+-------------------+---------------------------------+
| 4 | :attr:`tm_min` | range [0, 59] |
+-------+-------------------+---------------------------------+
| 5 | :attr:`tm_sec` | range [0, 61]; see **(1)** in |
| | | :func:`strftime` description |
+-------+-------------------+---------------------------------+
| 6 | :attr:`tm_wday` | range [0, 6], Monday is 0 |
+-------+-------------------+---------------------------------+
| 7 | :attr:`tm_yday` | range [1, 366] |
+-------+-------------------+---------------------------------+
| 8 | :attr:`tm_isdst` | 0, 1 or -1; see below |
+-------+-------------------+---------------------------------+
Note that unlike the C structure, the month value is a range of [1, 12],
not [0, 11].
A year value will be handled as described under "Year 2000 (Y2K) issues" above.
A ``-1`` argument as the daylight savings flag, passed to :func:`mktime` will
usually result in the correct daylight savings state to be filled in.
When a tuple with an incorrect length is passed to a function expecting a
:class:`struct_time`, or having elements of the wrong type, a :exc:`TypeError`
is raised.
* Use the following functions to convert between time representations: * Use the following functions to convert between time representations:
@ -389,10 +360,45 @@ The module defines the following functions and data items:
documented as supported. documented as supported.
.. data:: struct_time .. class:: struct_time
The type of the time value sequence returned by :func:`gmtime`, The type of the time value sequence returned by :func:`gmtime`,
:func:`localtime`, and :func:`strptime`. :func:`localtime`, and :func:`strptime`. It is an object with a :term:`named
tuple` interface: values can be accessed by index and by attribute name. The
following values are present:
+-------+-------------------+---------------------------------+
| Index | Attribute | Values |
+=======+===================+=================================+
| 0 | :attr:`tm_year` | (for example, 1993) |
+-------+-------------------+---------------------------------+
| 1 | :attr:`tm_mon` | range [1, 12] |
+-------+-------------------+---------------------------------+
| 2 | :attr:`tm_mday` | range [1, 31] |
+-------+-------------------+---------------------------------+
| 3 | :attr:`tm_hour` | range [0, 23] |
+-------+-------------------+---------------------------------+
| 4 | :attr:`tm_min` | range [0, 59] |
+-------+-------------------+---------------------------------+
| 5 | :attr:`tm_sec` | range [0, 61]; see **(1)** in |
| | | :func:`strftime` description |
+-------+-------------------+---------------------------------+
| 6 | :attr:`tm_wday` | range [0, 6], Monday is 0 |
+-------+-------------------+---------------------------------+
| 7 | :attr:`tm_yday` | range [1, 366] |
+-------+-------------------+---------------------------------+
| 8 | :attr:`tm_isdst` | 0, 1 or -1; see below |
+-------+-------------------+---------------------------------+
Note that unlike the C structure, the month value is a range of [1, 12], not
[0, 11]. A year value will be handled as described under :ref:`Year 2000
(Y2K) issues <time-y2kissues>` above. A ``-1`` argument as the daylight
savings flag, passed to :func:`mktime` will usually result in the correct
daylight savings state to be filled in.
When a tuple with an incorrect length is passed to a function expecting a
:class:`struct_time`, or having elements of the wrong type, a
:exc:`TypeError` is raised.
.. function:: time() .. function:: time()