Search code examples
nest-api

Time Data From Nest API In Correct Format?


I have noticed that the date and time fields being returned to me from the Nest API are not matching the format that the API documentation lists.

For my thermostat, I am getting the following for last_connection:

"last_connection": "2014-10-27T20:22:12.165Z"

But the API documentation lists it should be formatted as:

"last_connection": "2014-10-27T20:22:12+06:00"

Why is the Nest API returning milliseconds to me and why am I getting the character "Z" instead of the actual timezone offset that the date/time is coming from?


Solution

  • It looks like the example is incorrect with respect to the actual implementation. If you look at the API Reference you will see the time data is all in ISO 8601, which support both string types.

    This also means you should likely use a library to support ISO 8601, rather than manually parsing the string if possible.