Skip to content

Changed tz_offset to seconds, updated docstring #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Jun 22, 2020
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