I'm working on a school project, where we have to set the RTC on a microcontroller that runs mbedOS. The microcontroller fetches the current unix time, and time-zone offset from an api. I'm currently in Norway, so the offset is 2 hours from GMT.
When setting the UTC with the default mbedOS function, I can either do
set_time(unix_time);
or
set_time(unix_time + offset * 60 * 60); //Adjusts for my time zone
and when reading the time I must either do
ctime(&seconds)
or
ctime(&seconds) + offset * 60 * 60 //Adjusts for my time zone
Isin't there some better way to handle the time zone offset in MbedOS, so I don't have to adjust the time when reading, or setting it? Is there any built in function that handles time zones?