Skip to content

armgit / letta

Public Imported from GitHub
0

Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.

make timezone local by default (#298)

Charles Packer2d57564c356a
diff --git a/memgpt/utils.py b/memgpt/utils.py
index ff87fd17f..ace091634 100644
--- a/memgpt/utils.py
+++ b/memgpt/utils.py
@@ -60,12 +60,12 @@ def get_local_time_military():
return formatted_time
-def get_local_time():
+def get_local_time_timezone(timezone="America/Los_Angeles"):
# Get the current time in UTC
current_time_utc = datetime.now(pytz.utc)
# Convert to San Francisco's time zone (PST/PDT)
- sf_time_zone = pytz.timezone("America/Los_Angeles")
+ sf_time_zone = pytz.timezone(timezone)
local_time = current_time_utc.astimezone(sf_time_zone)
# You may format it as you desire, including AM/PM
@@ -74,6 +74,19 @@ def get_local_time():
return formatted_time
+def get_local_time(timezone=None):
+ if timezone is not None:
+ return get_local_time_timezone(timezone)
+ else:
+ # Get the current time, which will be in the local timezone of the computer
+ local_time = datetime.now()
+
+ # You may format it as you desire, including AM/PM
+ formatted_time = local_time.strftime("%Y-%m-%d %I:%M:%S %p %Z%z")
+
+ return formatted_time
+
+
def parse_json(string):
result = None
try: