[New-bugs-announce] [issue42679] Minor improvement in datetime.timestamp() docs

Olvin report at bugs.python.org
Fri Dec 18 16:36:55 EST 2020

New submission from Olvin <olvinroght at protonmail.com>:

Answering question on StackOverflow I've found next example in docs of datetime.timestamp() ( https://docs.python.org/3/library/datetime.html#datetime.datetime.timestamp ) which returns UTC timestamp:

timestamp = (dt - datetime(1970, 1, 1)) / timedelta(seconds=1)

While it works I think there's more explicit way using timedelta.total_seconds() :

timestamp = (dt - datetime(1970, 1, 1)).total_seconds()

In same article few lines above there's example using total_seconds() so I think it will be good to use same method in both examples.

assignee: docs at python
components: Documentation
messages: 383328
nosy: docs at python, olvinroght
priority: normal
severity: normal
status: open
title: Minor improvement in datetime.timestamp() docs
type: enhancement

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list