Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions adafruit_ntp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down