Skip to content

Commit

Permalink
Fixed timezone detection bug
Browse files Browse the repository at this point in the history
  • Loading branch information
tsbarnes committed Sep 9, 2021
1 parent 438c50c commit 7bf5376
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
11 changes: 6 additions & 5 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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()
10 changes: 8 additions & 2 deletions screens/calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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):
Expand Down

0 comments on commit 7bf5376

Please sign in to comment.