agent-Python-RobotFramework icon indicating copy to clipboard operation
agent-Python-RobotFramework copied to clipboard

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

Open d0b3rm4n opened this issue 1 year ago • 0 comments

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

d0b3rm4n avatar May 07 '24 15:05 d0b3rm4n