summaryrefslogtreecommitdiffstats
path: root/Doc/library/datetime.rst
diff options
context:
space:
mode:
authorYasser A <yalshalaan@gmail.com>2019-03-16 03:56:58 (GMT)
committerNick Coghlan <ncoghlan@gmail.com>2019-03-16 03:56:58 (GMT)
commitf40b4a0b6277b2779b9ded3736325489f2af93e4 (patch)
tree7b5e4c20387c2995d6a29faa7182202d1147d523 /Doc/library/datetime.rst
parentd2fdd1fedf6b9dc785cf5025b548a989faed089a (diff)
downloadcpython-f40b4a0b6277b2779b9ded3736325489f2af93e4.zip
cpython-f40b4a0b6277b2779b9ded3736325489f2af93e4.tar.gz
cpython-f40b4a0b6277b2779b9ded3736325489f2af93e4.tar.bz2
bpo-36138: Clarify docs about converting datetime.timedelta to scalars. (GH-12137)
Be explicit that timedelta division converts an overall duration to the interval units given by the denominator.
Diffstat (limited to 'Doc/library/datetime.rst')
-rw-r--r--Doc/library/datetime.rst8
1 files changed, 5 insertions, 3 deletions
diff --git a/Doc/library/datetime.rst b/Doc/library/datetime.rst
index 121f73b..1ee23c2 100644
--- a/Doc/library/datetime.rst
+++ b/Doc/library/datetime.rst
@@ -254,8 +254,9 @@ Supported operations:
| | rounded to the nearest multiple of |
| | timedelta.resolution using round-half-to-even.|
+--------------------------------+-----------------------------------------------+
-| ``f = t2 / t3`` | Division (3) of *t2* by *t3*. Returns a |
-| | :class:`float` object. |
+| ``f = t2 / t3`` | Division (3) of overall duration *t2* by |
+| | interval unit *t3*. Returns a :class:`float` |
+| | object. |
+--------------------------------+-----------------------------------------------+
| ``t1 = t2 / f or t1 = t2 / i`` | Delta divided by a float or an int. The result|
| | is rounded to the nearest multiple of |
@@ -351,7 +352,8 @@ Instance methods:
.. method:: timedelta.total_seconds()
Return the total number of seconds contained in the duration. Equivalent to
- ``td / timedelta(seconds=1)``.
+ ``td / timedelta(seconds=1)``. For interval units other than seconds, use the
+ division form directly (e.g. ``td / timedelta(microseconds=1)``).
Note that for very large time intervals (greater than 270 years on
most platforms) this method will lose microsecond accuracy.