reportportal / agent-Python-RobotFramework

Robot Framework integration for Report Portal
Apache License 2.0
59 stars 33 forks source link

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

Closed d0b3rm4n closed 2 months ago

d0b3rm4n commented 6 months ago

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
HardNorth commented 2 months ago

@d0b3rm4n These timestamps are being written in the local timezone, thus where you need UTC, one might need EST, or any other timezone. The only things I can do here is to add timezone configuration variable.

HardNorth commented 2 months ago

@d0b3rm4n Please use this version: https://github.com/reportportal/agent-Python-RobotFramework/releases/tag/5.5.6