Skip to content

Commit

Permalink
Manual timezone offset
Browse files Browse the repository at this point in the history
  • Loading branch information
bill88t committed Oct 20, 2024
1 parent 6f93279 commit 72ec45f
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions drivers/driver_wifi.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from socketpool import SocketPool
from ssl import create_default_context
from adafruit_requests import Session
from cptoml import fetch


class driver_wifi:
Expand Down Expand Up @@ -299,20 +300,10 @@ def timeset(self, tz=None) -> bool:
from time import struct_time

if tz is None:
if self.connected:
try:
utc_offset = self.get("https://worldtimeapi.org/api/ip").json()[
"utc_offset"
]
negative = utc_offset[0] != "+"
tz = int(utc_offset[1:3])
if negative:
tz = -tz
self.reset_session()
except:
return False
else:
return False
tz = fetch("tz_offset")

if tz is None:
tz = 2

if tz != self._tz:
self._tz = tz
Expand Down

0 comments on commit 72ec45f

Please sign in to comment.