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

to_timestamp() is not Timezone aware and leads to wrong times in ReportPortal #188

Open
d0b3rm4n opened this issue May 7, 2024 · 0 comments

Comments

@d0b3rm4n
Copy link

d0b3rm4n commented May 7, 2024

See:

dt = datetime.strptime(time_str, '%Y%m%d %H:%M:%S.%f')

I had always wrong times in Report Portal. I fixed it with:

from datetime import datetime, timedelta, timezone

def to_timestamp(time_str):
    if time_str:
        time = datetime.strptime(
            time_str, '%Y%m%d %H:%M:%S.%f').replace(tzinfo=timezone.utc)
        return str(int(time.timestamp() * 1000))
    return None
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

No branches or pull requests

1 participant