File tree 1 file changed +7
-4
lines changed
1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change 48
48
49
49
class NTP :
50
50
"""Network Time Protocol (NTP) helper module for CircuitPython.
51
- This module does not handle daylight savings or local time.
51
+ This module does not handle daylight savings time.
52
52
53
53
:param adafruit_esp32spi esp: ESP32SPI object.
54
54
"""
@@ -61,13 +61,16 @@ def __init__(self, esp):
61
61
raise TypeError ("Provided object is not an ESP_SPIcontrol object." )
62
62
self .valid_time = False
63
63
64
- def set_time (self ):
64
+ def set_time (self , tz_offset = 0 ):
65
65
"""Fetches and sets the microcontroller's current time
66
- in seconds since since Jan 1, 1970.
66
+ in seconds since since Jan 1, 1970. Optionally offsets
67
+ the current time to that of the requested timezone.
68
+
69
+ :param int tz_offset: Timezone offset from GMT in hours
67
70
"""
68
71
try :
69
72
now = self ._esp .get_time ()
70
- now = time .localtime (now [0 ])
73
+ now = time .localtime (now [0 ]+ ( tz_offset * 3600 )) # 3600 seconds in an hour
71
74
rtc .RTC ().datetime = now
72
75
self .valid_time = True
73
76
except ValueError :
You can’t perform that action at this time.
0 commit comments