diff --git a/adafruit_io/adafruit_io.py b/adafruit_io/adafruit_io.py index 085273c..ed1fc92 100755 --- a/adafruit_io/adafruit_io.py +++ b/adafruit_io/adafruit_io.py @@ -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): """ 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: + path += "?tz={0}".format(tz) time_struct = self._get(path) return time.struct_time( ( diff --git a/examples/adafruit_io_http/adafruit_io_groups.py b/examples/adafruit_io_http/adafruit_io_groups.py index a7f0809..12ab0d6 100644 --- a/examples/adafruit_io_http/adafruit_io_groups.py +++ b/examples/adafruit_io_http/adafruit_io_groups.py @@ -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())