diff --git a/agentops/session.py b/agentops/session.py index a82eeb355..f5722af4b 100644 --- a/agentops/session.py +++ b/agentops/session.py @@ -7,7 +7,7 @@ from termcolor import colored from typing import Optional, List, Union from uuid import UUID, uuid4 -from dateutil import parser +from datetime import datetime from .exceptions import ApiServerException from .enums import EndState @@ -106,7 +106,10 @@ def end_session( self._flush_queue() def format_duration(start_time, end_time): - duration = parser.parse(end_time) - parser.parse(start_time) + start = datetime.fromisoformat(start_time.replace("Z", "+00:00")) + end = datetime.fromisoformat(end_time.replace("Z", "+00:00")) + duration = end - start + hours, remainder = divmod(duration.total_seconds(), 3600) minutes, seconds = divmod(remainder, 60)