Skip to content

Commit

Permalink
Add tz arg (TimeZone) to receive_time
Browse files Browse the repository at this point in the history
  • Loading branch information
tyeth committed Jul 16, 2024
1 parent 3e231a1 commit 435dab5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion adafruit_io/adafruit_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -842,12 +842,16 @@ def receive_random_data(self, generator_id: int):
path = self._compose_path("integrations/words/{0}".format(generator_id))
return self._get(path)

def receive_time(self):
def receive_time(self, tz: str = None):

Check failure on line 845 in adafruit_io/adafruit_io.py

View workflow job for this annotation

GitHub Actions / test

Argument name "tz" doesn't conform to '(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$' pattern
"""
Returns a struct_time from the Adafruit IO Server based on the device's IP address.
https://circuitpython.readthedocs.io/en/latest/shared-bindings/time/__init__.html#time.struct_time
:param str tz: Timezone to return the time in, see https://io.adafruit.com/services/time
"""
path = self._compose_path("integrations/time/struct.json")
if tz is not None:

Check failure on line 853 in adafruit_io/adafruit_io.py

View workflow job for this annotation

GitHub Actions / test

Argument name "tz" doesn't conform to '(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$' pattern
path += "?tz={0}".format(tz)
time_struct = self._get(path)
return time.struct_time(
(
Expand Down
2 changes: 1 addition & 1 deletion examples/adafruit_io_http/adafruit_io_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@

# fetch current time
print("Fetching current time from IO... ", end="")
year, month, day, hour, minute, second, *_ = io.receive_time()
year, month, day, hour, minute, second, *_ = io.receive_time(tz="UTC")
old_time = datetime.datetime(year, month, day, hour, minute, second)
print(old_time.isoformat())

Expand Down

0 comments on commit 435dab5

Please sign in to comment.