Skip to content

Commit

Permalink
porting from dateutil to datetime
Browse files Browse the repository at this point in the history
  • Loading branch information
HowieG committed Sep 18, 2024
1 parent 1f47194 commit 3a3f5e1
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions agentops/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 3a3f5e1

Please sign in to comment.