Fix TZ Issues

This commit is contained in:
2025-09-10 10:22:43 -05:00
parent 175d30abc9
commit c32875223c
2 changed files with 9 additions and 3 deletions

8
app.py
View File

@@ -713,7 +713,9 @@ async def lastcleanup(ctx):
return return
last_run_dt_utc = datetime.datetime.fromisoformat(last_run) last_run_dt_utc = datetime.datetime.fromisoformat(last_run)
last_run_local = pytz.utc.localize(last_run_dt_utc).astimezone(LOCAL_TZ) if last_run_dt_utc.tzinfo is None:
last_run_dt_utc = pytz.utc.localize(last_run_dt_utc)
last_run_local = last_run_dt_utc.astimezone(LOCAL_TZ)
now_local = datetime.datetime.now(LOCAL_TZ) now_local = datetime.datetime.now(LOCAL_TZ)
next_run_local = last_run_local + datetime.timedelta(hours=24) next_run_local = last_run_local + datetime.timedelta(hours=24)
time_remaining = next_run_local - now_local time_remaining = next_run_local - now_local
@@ -1115,7 +1117,9 @@ async def on_ready():
# parse UTC timestamp from DB # parse UTC timestamp from DB
last_run_dt_utc = datetime.datetime.fromisoformat(last_run) last_run_dt_utc = datetime.datetime.fromisoformat(last_run)
# convert to local timezone # convert to local timezone
last_run_local = pytz.utc.localize(last_run_dt_utc).astimezone(LOCAL_TZ) if last_run_dt_utc.tzinfo is None:
last_run_dt_utc = pytz.utc.localize(last_run_dt_utc)
last_run_local = last_run_dt_utc.astimezone(LOCAL_TZ)
now_local = datetime.datetime.now(LOCAL_TZ) now_local = datetime.datetime.now(LOCAL_TZ)
delta = now_local - last_run_local delta = now_local - last_run_local
if delta.total_seconds() >= 24 * 3600: if delta.total_seconds() >= 24 * 3600:

View File

@@ -1,4 +1,6 @@
discord.py==2.3.2 discord.py==2.3.2
requests==2.32.3 requests==2.32.3
mysql-connector-python==9.0.0 mysql-connector-python==9.0.0
python-dotenv==1.0.1 python-dotenv==1.0.1
pytz==2025.2
apscheduler==3.11.0