From d4757e3a2e6b34e1d74534185eb5ab196c1401c4 Mon Sep 17 00:00:00 2001
From: fmk17 <fmk17@inf.ufpr.br>
Date: Thu, 10 Feb 2022 10:09:40 -0300
Subject: [PATCH] Fix logging and timezone issues

---
 main.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/main.py b/main.py
index c790916..a7e3737 100644
--- a/main.py
+++ b/main.py
@@ -249,7 +249,7 @@ def invalid_button(update: Update, context: CallbackContext) -> None:
     update.callback_query.answer(text="Essa mensagem não é mais válida", show_alert=True)
 
 def send_scheduled(context: CallbackContext) -> None:
-    time = context.job.next_t - timedelta(minutes=EVERY_X_MINUTES)
+    time = context.job.next_t.astimezone() - timedelta(minutes=EVERY_X_MINUTES)
     logging.info(f"Getting schedules matching {time}")
     schedules = get_schedules_matching_time(time)
     for schedule in schedules:
@@ -270,7 +270,7 @@ def send_scheduled(context: CallbackContext) -> None:
             header + '\n\n' + body + '\n\n' + updated_on,
             parse_mode=PARSEMODE_HTML
         )
-        logger.info(f"User {update.effective_user.id} {update.effective_user.first_name} {update.effective_user.last_name} {update.effective_user.username} received schedule {pformat(schedule)}")
+        logger.info(f"User {schedule.user_id} received schedule {pformat(schedule)}")
 
 EVERY_X_MINUTES = 15
 
-- 
GitLab