Skip to content

Commit 72ec45f

Browse files
committed
Manual timezone offset
1 parent 6f93279 commit 72ec45f

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

drivers/driver_wifi.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from socketpool import SocketPool
44
from ssl import create_default_context
55
from adafruit_requests import Session
6+
from cptoml import fetch
67

78

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

301302
if tz is None:
302-
if self.connected:
303-
try:
304-
utc_offset = self.get("https://worldtimeapi.org/api/ip").json()[
305-
"utc_offset"
306-
]
307-
negative = utc_offset[0] != "+"
308-
tz = int(utc_offset[1:3])
309-
if negative:
310-
tz = -tz
311-
self.reset_session()
312-
except:
313-
return False
314-
else:
315-
return False
303+
tz = fetch("tz_offset")
304+
305+
if tz is None:
306+
tz = 2
316307

317308
if tz != self._tz:
318309
self._tz = tz

0 commit comments

Comments
 (0)