Convert UNIX time to string variable
In the example "examples/Onecall API (subscription required)/My_OpenWeather_Test/My_OpenWeather_Test.ino", there is a define, #define TIME_OFFSET 1UL * 3600UL // UTC + 0 hour
I'm trying to understand how I can set the offset given this example, when the unsigned long variables are used but my timezone offset is -5? Please forgive me as I am extremely novice when it comes to C & C++.
String strTime(time_t unixTime) { unixTime += TIME_OFFSET; return ctime(&unixTime); }
This should work:
#define TIME_OFFSET -5 * 3600
You might need to cast the time_t type if you get a compile error:
unixTime = (time_t)((int32_t)unixTime + (int32_t)(TIME_OFFSET));
This should work:
#define TIME_OFFSET -5 * 3600
You might need to cast the time_t type if you get a compile error:
unixTime = (time_t)((int32_t)unixTime + (int32_t)(TIME_OFFSET));
Thanks @Bodmer, any chance you might end up porting the Openweather API to PlatformIO? I noticed JSON_Decoder was available in the repo but didn't find Openweather in there.
+1 on platformio..struggling to get this in IDE