Skip to content
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

mistake in the timedelta.total_seconds docstring #63027

Closed
allo mannequin opened this issue Aug 24, 2013 · 3 comments
Closed

mistake in the timedelta.total_seconds docstring #63027

allo mannequin opened this issue Aug 24, 2013 · 3 comments
Labels
docs Documentation in the Doc dir type-bug An unexpected behavior, bug, or error

Comments

@allo
Copy link
Mannequin

allo mannequin commented Aug 24, 2013

BPO 18827
Nosy @tim-one

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2013-08-24.22:31:42.984>
created_at = <Date 2013-08-24.22:05:21.131>
labels = ['type-bug', 'invalid', 'docs']
title = 'mistake in the timedelta.total_seconds docstring'
updated_at = <Date 2013-08-24.22:31:42.982>
user = 'https://bugs.python.org/allo'

bugs.python.org fields:

activity = <Date 2013-08-24.22:31:42.982>
actor = 'allo'
assignee = 'docs@python'
closed = True
closed_date = <Date 2013-08-24.22:31:42.984>
closer = 'allo'
components = ['Documentation']
creation = <Date 2013-08-24.22:05:21.131>
creator = 'allo'
dependencies = []
files = []
hgrepos = []
issue_num = 18827
keywords = []
message_count = 3.0
messages = ['196100', '196101', '196102']
nosy_count = 3.0
nosy_names = ['tim.peters', 'docs@python', 'allo']
pr_nums = []
priority = 'normal'
resolution = 'not a bug'
stage = None
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue18827'
versions = ['Python 2.7']

@allo
Copy link
Mannequin Author

allo mannequin commented Aug 24, 2013

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.

Should be

Return the total number of seconds contained in the duration. Equivalent to (td.microseconds / 10**6 + (td.seconds + td.days * 24 * 3600) * 10**6) computed with true division enabled.

At least i hope, the bug is only in the docs and not in the function ;).

@allo allo mannequin assigned docspython Aug 24, 2013
@allo allo mannequin added docs Documentation in the Doc dir type-bug An unexpected behavior, bug, or error labels Aug 24, 2013
@tim-one
Copy link
Member

tim-one commented Aug 24, 2013

The docs look correct to me. For example,

>>> from datetime import *
>>> td = datetime.now() - datetime(1,1,1)
>>> td
datetime.timedelta(735103, 61756, 484000)
>>> td.total_seconds()
63512960956.484
                                                                ^
What the docs say match that output:

>>> (td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6) / 1e6
63512960956.484

Your suggestion's output:

>>> (td.microseconds / 1e6 + (td.seconds + td.days * 24 * 3600) * 10**6)
6.3512960956e+16

You're multiplying the number seconds by a million - not a good idea ;-)

@allo
Copy link
Mannequin Author

allo mannequin commented Aug 24, 2013

Err, sorry my fault. Too late in the evening ;).

I saw the division by one million, but not the multiplation by one million before. Additionally i was confused, because i expected that seconds are added to each other in the parenthesis.

closing.

@allo allo mannequin closed this as completed Aug 24, 2013
@allo allo mannequin added the invalid label Aug 24, 2013
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant