Skip to content

Commit

Permalink
make timezone local by default (letta-ai#298)
Browse files Browse the repository at this point in the history
Co-authored-by: orderwat <github@oderwat.de>
  • Loading branch information
cpacker and oderwat authored Nov 4, 2023
1 parent 26ba63c commit ed0c935
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions memgpt/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down

0 comments on commit ed0c935

Please sign in to comment.