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

handle negative timestamps on Windows #176

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

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.

1 participant