From 7bf537657f1537e364e39600fdcfabaa2f9e58ea Mon Sep 17 00:00:00 2001 From: Thea Barnes Date: Thu, 9 Sep 2021 15:06:40 -0400 Subject: [PATCH] Fixed timezone detection bug --- app.py | 11 ++++++----- screens/calendar.py | 10 ++++++++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/app.py b/app.py index 35fa89d..a3120d7 100644 --- a/app.py +++ b/app.py @@ -74,6 +74,12 @@ def get_screen_by_name(self, screen_name): return None def __init__(self): + if DEBUG: + logging.basicConfig(level=logging.DEBUG, filename=LOGFILE) + logging.info("Debug messages enabled") + else: + logging.basicConfig(filename=LOGFILE) + self.mq = posix_ipc.MessageQueue("/epdtext_ipc", flags=posix_ipc.O_CREAT) self.mq.block = False @@ -144,10 +150,5 @@ def loop(self): self.current_screen().print_to_display() -if DEBUG: - logging.basicConfig(level=logging.DEBUG) -if LOGFILE: - logging.basicConfig(filename=LOGFILE) - app = App() app.loop() diff --git a/screens/calendar.py b/screens/calendar.py index f4e07a6..4f8aa5b 100644 --- a/screens/calendar.py +++ b/screens/calendar.py @@ -3,7 +3,7 @@ import caldav import logging import pytz -from datetime import date, datetime, timedelta +from datetime import date, datetime, timedelta, tzinfo from icalevents.icalevents import events from settings import CALENDAR_URLS, TIMEZONE @@ -13,7 +13,13 @@ def sort_by_date(obj): class Calendar: - timezone = pytz.timezone(TIMEZONE) + timezone = None + + def __init__(self): + if isinstance(TIMEZONE, tzinfo): + self.timezone = TIMEZONE + else: + self.timezone = pytz.timezone(TIMEZONE) def standardize_date(self, arg, ignore_timezone=False): if isinstance(arg, datetime) and (not arg.tzinfo or ignore_timezone):