mirror of
https://github.com/python/cpython
synced 2026-09-29 12:10:30 +03:00
Issue #1667546: On platforms supporting tm_zone and tm_gmtoff fields
in struct tm, time.struct_time objects returned by time.gmtime(), time.localtime() and time.strptime() functions now have tm_zone and tm_gmtoff attributes. Original patch by Paul Boddie.
This commit is contained in:
parent
f6a899fe6d
commit
c142bba2a7
6 changed files with 117 additions and 9 deletions
|
|
@ -77,6 +77,12 @@ An explanation of some terminology and conventions is in order.
|
|||
|
||||
See :class:`struct_time` for a description of these objects.
|
||||
|
||||
.. versionchanged:: 3.3
|
||||
|
||||
The :class:`struct_time` type was extended to provide the
|
||||
:attr:`tm_gmtoff` and :attr:`tm_zone` attributes when platform
|
||||
supports corresponding ``struct tm`` members.
|
||||
|
||||
* Use the following functions to convert between time representations:
|
||||
|
||||
+-------------------------+-------------------------+-------------------------+
|
||||
|
|
@ -336,7 +342,6 @@ The module defines the following functions and data items:
|
|||
|
||||
.. versionadded:: 3.3
|
||||
|
||||
|
||||
.. function:: sleep(secs)
|
||||
|
||||
Suspend execution for the given number of seconds. The argument may be a
|
||||
|
|
@ -433,6 +438,12 @@ The module defines the following functions and data items:
|
|||
| ``%Y`` | Year with century as a decimal number. | |
|
||||
| | | |
|
||||
+-----------+------------------------------------------------+-------+
|
||||
| ``%z`` | Time zone offset indicating a positive or | |
|
||||
| | negative time difference from UTC/GMT of the | |
|
||||
| | form +HHMM or -HHMM, where H represents decimal| |
|
||||
| | hour digits and M represents decimal minute | |
|
||||
| | digits [-23:59, +23:59]. | |
|
||||
+-----------+------------------------------------------------+-------+
|
||||
| ``%Z`` | Time zone name (no characters if no time zone | |
|
||||
| | exists). | |
|
||||
+-----------+------------------------------------------------+-------+
|
||||
|
|
@ -532,6 +543,10 @@ The module defines the following functions and data items:
|
|||
+-------+-------------------+---------------------------------+
|
||||
| 8 | :attr:`tm_isdst` | 0, 1 or -1; see below |
|
||||
+-------+-------------------+---------------------------------+
|
||||
| N/A | :attr:`tm_zone` | abbreviation of timezone name |
|
||||
+-------+-------------------+---------------------------------+
|
||||
| N/A | :attr:`tm_gmtoff` | offset from UTC in seconds |
|
||||
+-------+-------------------+---------------------------------+
|
||||
|
||||
Note that unlike the C structure, the month value is a range of [1, 12], not
|
||||
[0, 11]. A ``-1`` argument as the daylight
|
||||
|
|
@ -542,6 +557,11 @@ The module defines the following functions and data items:
|
|||
:class:`struct_time`, or having elements of the wrong type, a
|
||||
:exc:`TypeError` is raised.
|
||||
|
||||
.. versionchanged:: 3.3
|
||||
|
||||
:attr:`tm_gmtoff` and :attr:`tm_zone` attributes are avaliable on
|
||||
platforms with C library supporting the corresponding fields in
|
||||
``struct tm``.
|
||||
|
||||
.. function:: time()
|
||||
|
||||
|
|
@ -552,7 +572,6 @@ The module defines the following functions and data items:
|
|||
lower value than a previous call if the system clock has been set back between
|
||||
the two calls.
|
||||
|
||||
|
||||
.. data:: timezone
|
||||
|
||||
The offset of the local (non-DST) timezone, in seconds west of UTC (negative in
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue