-
-
Notifications
You must be signed in to change notification settings - Fork 31k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bpo-29026: Clarify documentation of time.time #34
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,9 +19,16 @@ An explanation of some terminology and conventions is in order. | |
|
||
.. index:: single: epoch | ||
|
||
* The :dfn:`epoch` is the point where the time starts. On January 1st of that | ||
year, at 0 hours, the "time since the epoch" is zero. For Unix, the epoch is | ||
1970. To find out what the epoch is, look at ``gmtime(0)``. | ||
* The :dfn:`epoch` is the point where the time starts, and is platform | ||
dependent. For Unix, the epoch is January 1, 1970, 00:00:00 (UTC). | ||
To find out what the epoch is on a given platform, look at ``gmtime(0)``. | ||
|
||
.. index:: seconds since the epoch | ||
|
||
* The term :dfn:`seconds since the epoch` refers to the total number | ||
of elapsed seconds since the epoch, typically excluding | ||
`leap seconds <https://en.wikipedia.org/wiki/Leap_second>`_. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd say add .. `leap seconds`: https://en.wikipedia.org/wiki/Leap_second and use `leap-seconds`_ everytime you need the Wikipedia article. (I might the syntax got wrong so please try first :)) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added in d387bf7, also changed one other mention of leap seconds to link. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Whoops, failed to add to amended commit before push - added that other mention in 263a4f4 |
||
Leap seconds are excluded from this total on all POSIX-compliant platforms. | ||
|
||
.. index:: single: Year 2038 | ||
|
||
|
@@ -572,12 +579,27 @@ The module defines the following functions and data items: | |
|
||
.. function:: time() | ||
|
||
Return the time in seconds since the epoch as a floating point number. | ||
Return the time in seconds since the epoch as a floating point | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should add a link on the "epoch" word to its definition. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added link in d387bf7 |
||
number. The specific date of the epoch and the handling of | ||
`leap seconds <https://en.wikipedia.org/wiki/Leap_second>`_ | ||
is platform dependent. | ||
On Windows and most Unix systems, the epoch is January 1, 1970, | ||
00:00:00 (UTC) and leap seconds are not counted towards the time | ||
in seconds since the epoch. This is commonly referred to as | ||
`Unix time <https://en.wikipedia.org/wiki/Unix_time>`_. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMHO it's worth it to repeat here: To find out what the epoch is on a given platform, look at There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Repeated in d387bf7 |
||
|
||
Note that even though the time is always returned as a floating point | ||
number, not all systems provide time with a better precision than 1 second. | ||
While this function normally returns non-decreasing values, it can return a | ||
lower value than a previous call if the system clock has been set back between | ||
the two calls. | ||
lower value than a previous call if the system clock has been set back | ||
between the two calls. | ||
|
||
The number returned by :func:`time` may be converted into a more common | ||
time format (i.e. year, month, day, hour, etc...) in UTC by passing it to | ||
:func:`gmtime` function or in local time by passing it to the | ||
:func:`localtime` function. In both cases a :class:`struct_time` object | ||
is returned, from which the components of the calendar date may be accessed | ||
as attributes. | ||
|
||
.. data:: timezone | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume
gmtime(0)
istime.gmtime(0)
here. If I'm correct, we can use this as an opportunity to make it clearer.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it to
time.gmtime(0)
where it first appears in d387bf7. However, when the statement is repeated in the documentation oftime.time
, I retaingmtime(0)
as this appears to be the convention used in all the function docs for the module.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, failed to amend commit before pushing, I fixed to use doc conventions in 263a4f4