From 3a3f5e13271635e4c9646f5a2cd71533e080c2eb Mon Sep 17 00:00:00 2001 From: Howard Gil Date: Wed, 18 Sep 2024 15:56:22 -0700 Subject: [PATCH] porting from dateutil to datetime --- agentops/session.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/agentops/session.py b/agentops/session.py index a82eeb35..f5722af4 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)