classification
Title: Improve documentation about converting datetime.timedelta to scalars
Type: Stage: patch review
Components: Documentation, Library (Lib) Versions: Python 3.8, Python 3.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: Yasser Alshalaan, belopolsky, docs@python, fdrake, miss-islington, ncoghlan, p-ganssle
Priority: normal Keywords: patch

Created on 2019-02-27 14:54 by p-ganssle, last changed 2019-03-16 05:34 by ncoghlan.

Pull Requests
URL Status Linked Edit
PR 12137 merged Yasser Alshalaan, 2019-03-02 04:58
PR 12362 merged miss-islington, 2019-03-16 03:57
Messages (5)
msg336765 - (view) Author: Paul Ganssle (p-ganssle) * (Python committer) Date: 2019-02-27 14:54
In a recent python-dev thread, there was some confusion about how to get something like `timedelta.total_microseconds()`. There is already an existing, supported idiom for this, which is that `timedelta` implements division:

    td = timedelta(hours=1)
    num_microseconds = td / timedelta(microseconds=1)

In this e-mail ( https://mail.python.org/pipermail/python-dev/2019-February/156351.html ), Nick Coghlan proposed that we update the documentation and there were no objections, quoting:

    * In the "Supported Operations" section of https://docs.python.org/3/library/datetime.html#timedelta-objects,
      change "Division (3) of t2 by t3." to "Division (3) of overall
      duration t2 by interval unit t3."
    * In the total_seconds() documentation, add a sentence "For interval units
      other than seconds, use the division form directly (e.g. `td / timedelta(microseconds=1)`)"


I am starting this issue to track that change.
msg336980 - (view) Author: Yasser Alshalaan (Yasser Alshalaan) * Date: 2019-03-02 02:29
I'll do this in a moment I'll have the PR
msg338052 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2019-03-16 03:57
New changeset f40b4a0b6277b2779b9ded3736325489f2af93e4 by Nick Coghlan (Yasser A) in branch 'master':
bpo-36138: Clarify docs about converting datetime.timedelta to scalars. (GH-12137)
https://github.com/python/cpython/commit/f40b4a0b6277b2779b9ded3736325489f2af93e4
msg338053 - (view) Author: miss-islington (miss-islington) Date: 2019-03-16 04:03
New changeset e213cd6325f2d6f116b6c3dce109cdf21f6263d5 by Miss Islington (bot) in branch '3.7':
bpo-36138: Clarify docs about converting datetime.timedelta to scalars. (GH-12137)
https://github.com/python/cpython/commit/e213cd6325f2d6f116b6c3dce109cdf21f6263d5
msg338054 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2019-03-16 05:34
I've merged Yasser's PR (thank you!), but in the review discussion for that, we noticed something else: the `total_seconds()` documentation mentions the floating point dynamic resolution problem, but doesn't mention using `//` or `divmod()` as the fix for that, while the operator table doesn't mention the dynamic resolution problem at all.

So I haven't closed the issue yet, as fixing that feel in-scope for this issue, even though I didn't want to hold up the initial PR for it.
History
Date User Action Args
2019-03-16 05:34:12ncoghlansetmessages: + msg338054
2019-03-16 04:03:46miss-islingtonsetnosy: + miss-islington
messages: + msg338053
2019-03-16 03:57:57miss-islingtonsetpull_requests: + pull_request12329
2019-03-16 03:57:00ncoghlansetmessages: + msg338052
2019-03-02 05:42:27Yasser Alshalaansetpull_requests: - pull_request12138
2019-03-02 04:58:48Yasser Alshalaansetpull_requests: + pull_request12139
2019-03-02 03:29:25Yasser Alshalaansetkeywords: + patch
stage: patch review
pull_requests: + pull_request12138
2019-03-02 02:29:09Yasser Alshalaansetnosy: + Yasser Alshalaan
messages: + msg336980
2019-02-27 16:06:14fdrakesetnosy: + fdrake
2019-02-27 14:54:37p-gansslecreate