From b0f2b49f6d73738e7b234d3118af64c31136635a Mon Sep 17 00:00:00 2001 From: EldarAlvik Date: Thu, 7 Nov 2024 22:08:15 +0100 Subject: [PATCH] Feat: added timezone to current time --- core/requirements.txt | Bin 2008 -> 2032 bytes core/tools/current_time_iso.py | 8 ++++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/requirements.txt b/core/requirements.txt index 6885a17e64b46932f055fd39a4ed83b758bcbcd8..984f3176d4d73ca2b9909534cf90abcc4e535abb 100644 GIT binary patch delta 32 jcmcb?|ABwQ4R(nFhDwGKhAIYIAT(ky0AdpcJs=4Hou&r| delta 7 Ocmeyse}jL+4R!zzECY4` diff --git a/core/tools/current_time_iso.py b/core/tools/current_time_iso.py index 371f666..657bf58 100644 --- a/core/tools/current_time_iso.py +++ b/core/tools/current_time_iso.py @@ -2,9 +2,8 @@ from langchain_core.tools import tool from pydantic import BaseModel, Field from langchain_core.tools.structured import StructuredTool -from datetime import datetime - - +from datetime import datetime, timezone +import pytz #Dormamu I've come to bargain @@ -17,7 +16,8 @@ def current_time_iso_format(basetool): Returns: str: The current time in ISO format. """ - time = datetime.now().replace(microsecond=0).strftime('%Y-%m-%dT%H:%M:%S') + timezone = pytz.timezone('Europe/Stockholm') + time = datetime.now(timezone).replace(microsecond=0).strftime('%Y-%m-%dT%H:%M:%S') return time def get_tool() -> StructuredTool: