diff --git a/adafruit_ntp.py b/adafruit_ntp.py index 1a4a27a..6297ebf 100644 --- a/adafruit_ntp.py +++ b/adafruit_ntp.py @@ -25,18 +25,15 @@ Network Time Protocol (NTP) helper for CircuitPython - -* Author(s): Brent Rubell + * Author(s): Brent Rubell Implementation Notes -------------------- - **Hardware:** - **Software and Dependencies:** -* Adafruit CircuitPython firmware for the supported boards: - https://github.com/adafruit/circuitpython/releases + * Adafruit CircuitPython firmware for the supported boards: + https://github.com/adafruit/circuitpython/releases """ import time @@ -65,11 +62,14 @@ def set_time(self, tz_offset=0): """Fetches and sets the microcontroller's current time in seconds since since Jan 1, 1970. - :param int tz_offset: Timezone offset from GMT + :param int tz_offset: The offset of the local timezone, + in seconds west of UTC (negative in most of Western Europe, + positive in the US, zero in the UK). """ + try: now = self._esp.get_time() - now = time.localtime(now[0] + (tz_offset * 3600)) # 3600 seconds in an hour + now = time.localtime(now[0] + tz_offset) rtc.RTC().datetime = now self.valid_time = True except ValueError as error: