mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Issue #8644: Improve accuracy of timedelta.total_seconds, by doing intermediate
computations with integer arithmetic instead of floating point. td.total_seconds() now agrees with td / timedelta(seconds = 1). Thanks Alexander Belopolsky for the patch.
This commit is contained in:
parent
161b024b6d
commit
0381e3f16a
4 changed files with 33 additions and 4 deletions
|
@ -287,7 +287,10 @@ Instance methods:
|
|||
.. method:: timedelta.total_seconds()
|
||||
|
||||
Return the total number of seconds contained in the duration. Equivalent to
|
||||
``td.microseconds / 1000000 + td.seconds + td.days * 24 * 3600``.
|
||||
``td / timedelta(seconds=1)``.
|
||||
|
||||
Note that for very large time intervals (greater than 270 years on
|
||||
most platforms) this method will lose microsecond accuracy.
|
||||
|
||||
.. versionadded:: 3.2
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue