diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2010-05-09 09:30:06 +0000 |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2010-05-09 09:30:06 +0000 |
commit | 7000e9e01bb784dfc23a70a9d736613ae83c8dad (patch) | |
tree | 993dfea355ae52e05bf1d81ad01dd16790869f3b /Doc/library | |
parent | 860852fdf434cb566ace9879ba2a6be0e2569765 (diff) | |
download | cpython-git-7000e9e01bb784dfc23a70a9d736613ae83c8dad.tar.gz |
Issue #8644: Improve accuracy of timedelta.total_seconds method.
(Backport of r80979 to py3k.) Thanks Alexander Belopolsky.
Diffstat (limited to 'Doc/library')
-rw-r--r-- | Doc/library/datetime.rst | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Doc/library/datetime.rst b/Doc/library/datetime.rst index 16429de5b6..d612e8731c 100644 --- a/Doc/library/datetime.rst +++ b/Doc/library/datetime.rst @@ -270,8 +270,12 @@ 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``. + Return the total number of seconds contained in the duration. + Equivalent to ``(td.microseconds + (td.seconds + td.days * 24 * + 3600) * 10**6) / 10**6`` computed with true division enabled. + + Note that for very large time intervals (greater than 270 years on + most platforms) this method will lose microsecond accuracy. .. versionadded:: 2.7 |