agent-Python-RobotFramework
agent-Python-RobotFramework copied to clipboard
to_timestamp() is not Timezone aware and leads to wrong times in ReportPortal
See: https://github.com/reportportal/agent-Python-RobotFramework/blob/bbceeb50b54ae085e74fa9fde13101c331301a77/robotframework_reportportal/result_visitor.py#L33
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