Skip to content

Conversation

@jsta
Copy link

@jsta jsta commented Jan 21, 2022

@jsta
Copy link
Author

jsta commented Jan 22, 2022

The current and proposed code give identical outputs on Linux but only the proposed code works on Windows:

import datetime

timestamp_ms = -50000

# current 
datetime.datetime.utcfromtimestamp(timestamp_ms / 1000.0).isoformat() + "Z"

# proposed
(
    datetime.datetime.utcfromtimestamp(0)
    + datetime.timedelta(seconds=timestamp_ms / 1000)
).isoformat() + "Z"

@jsta
Copy link
Author

jsta commented Nov 2, 2022

This allows for handling dates pre-1970

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants