Title: Minor improvement in datetime.timestamp() docs
Type: enhancement Stage:
Components: Documentation Versions:
Status: open Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, olvinroght
Priority: normal Keywords:

Created on 2020-12-18 21:36 by olvinroght, last changed 2020-12-18 21:36 by olvinroght.

Messages (1)
msg383328 - (view) Author: Olvin (olvinroght) Date: 2020-12-18 21:36
Answering question on StackOverflow I've found next example in docs of 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.
Date User Action Args
2020-12-18 21:36:55olvinroghtcreate