0

Time Service
Moderators: adafruit_support_bill, adafruit

Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
Please be positive and constructive with your questions and comments.

Time Service

by davegun on Sat Jan 04, 2020 2:16 pm

I'm trying to understand how the Time Service works. I found https://io.adafruit.com/username/services/time. I also found the example "adafruitio_17_time_subscribe".

Using the information from https://io.adafruit.com/username/services/time: When I enter https://io.adafruit.com//api/v2/time/ISO-8601 , I get the time as expected.

I would now like to get the current time in my time zone. The instructions for /integrations HTTP API say:
GET /api/v2/:username/integrations/time
Parameters:
tz [OPTIONAL] Timezone to get the current time for.

My time zone is "America/Chicago", so what do I type into my browser to get a proper response?

My goal is to modify the example "adafruitio_17_time_subscribe" sketch to print the time with time zone offset. Once I figure this out, I should be able to use it in my project sketch.

Thanks,

Dave

davegun
 
Posts: 89
Joined: Sun Sep 08, 2013 11:00 pm

Re: Time Service

by brubell on Mon Jan 06, 2020 11:47 am

tz should be included in the body of the HTTP request. You will not be able to do this via your browser's URL bar, you'll need a tool such as CURL.


Here's an example of the request for obtaining ISO-8601 with USA East Coast time:
Code: Select all | TOGGLE FULL SIZE
curl -X GET -d 'tz: US' -v -i 'https://io.adafruit.com//api/v2/time/ISO-8601'


Here's a website which let's you try out API requests from your browser, I already set it up to mimic the CURL example above:
http://apirequest.io/5e1352db9fdf4a065f ... ST5kyHQqJg


Adafruit IO Arduino uses the MQTT API, not the HTTP API. Unfortunately, that API does not allow you to pass in a configurable timezone (MQTT is a bit restrictive in this sense) and you will need to obtain the time, and perform timezone calculations inside the code which runs on your device
- brent r.

brubell
 
Posts: 696
Joined: Fri Jul 17, 2015 10:33 pm

Re: Time Service

by davegun on Sat Jan 11, 2020 5:03 pm

Bent,

That helped, thanks!

Dave

davegun
 
Posts: 89
Joined: Sun Sep 08, 2013 11:00 pm

Please be positive and constructive with your questions and comments.