This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC3235S: Getting UTC time and local time of given time zone

Part Number: CC3235S


Hi,

I am using CC3235S module. In my application, I want to get UTC time as well as time of given time zone. Currently I am getting UTC time using below code:

_i8 configOpt = SL_DEVICE_GENERAL_DATE_TIME;
SlDateTime_t dt;

sl_DeviceGet(SL_DEVICE_GENERAL, &configOpt,
sizeof(SlDateTime_t), (unsigned char *)(&dt));

How to get time of a given time zone? I referred local_time example in SDK and I could find API's like ClockSync_setTimeZone() and ClockSync_get(&netTime). 

If I set time zone using  ClockSync_setTimeZone() then will ClockSync_get(&netTime) returns time of the set time zone? If yes, will I still be able to get UTC time using my existing code given above?

If there is any other solution to get both UTC time as well as time as time zone then please suggest.

Thanks,
Pradeep

  • ClockSync (see implementation under source/ti/net/utils) is a software module that works on top the MCU RTC. it uses SNTP to keep track of UTC. When using this module, only ClockSync_get() can be used to read the time (it does not update the RTC but keeping the offsets from UTC).

    It is also the only module that handles that takes the time-zone into account.

    If ClockSync  is used, you can also set it to update NWP clock (and then it the NWP will include time-zone offset).

    sl_DeviceGet() - reads the time from the NWP.  

    So basically, it is up to the user to decide whether to use UTC and handle time-zone by himself or let ClockSync handle it (then he will need to convert back to UTC when needed).

    You can SNTP directly to update NWP (see source/ti/net/sntp) so it will maintain UTC clock and then you can sl_DeviceGet to read the UTC and ClockSync_get() to read with time-zone. NWP just needs the date for the certificates validation so time-zone shouldn't make an big impact.