Skip to content

Commit 435dab5

Browse files
committed
Add tz arg (TimeZone) to receive_time
1 parent 3e231a1 commit 435dab5

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

adafruit_io/adafruit_io.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -842,12 +842,16 @@ def receive_random_data(self, generator_id: int):
842842
path = self._compose_path("integrations/words/{0}".format(generator_id))
843843
return self._get(path)
844844

845-
def receive_time(self):
845+
def receive_time(self, tz: str = None):
846846
"""
847847
Returns a struct_time from the Adafruit IO Server based on the device's IP address.
848848
https://circuitpython.readthedocs.io/en/latest/shared-bindings/time/__init__.html#time.struct_time
849+
850+
:param str tz: Timezone to return the time in, see https://io.adafruit.com/services/time
849851
"""
850852
path = self._compose_path("integrations/time/struct.json")
853+
if tz is not None:
854+
path += "?tz={0}".format(tz)
851855
time_struct = self._get(path)
852856
return time.struct_time(
853857
(

examples/adafruit_io_http/adafruit_io_groups.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106

107107
# fetch current time
108108
print("Fetching current time from IO... ", end="")
109-
year, month, day, hour, minute, second, *_ = io.receive_time()
109+
year, month, day, hour, minute, second, *_ = io.receive_time(tz="UTC")
110110
old_time = datetime.datetime(year, month, day, hour, minute, second)
111111
print(old_time.isoformat())
112112

0 commit comments

Comments
 (0)