2021-08-28 12:48 AM
Is there any function or library associated with STM32 Device to convert the UTC time to Local Time and Vice versa ?
Solved! Go to Solution.
2021-08-28 01:43 PM
Use the standard C-library functions prototyped in <time. h> to convert the date/time to UNIX epoch-based time, add or subtract the timezone-specific amount, then convert back.
You'll still have to supply the rules,it is application-specific how rigorously have they (mainly DST) be observed (e.g. if historical data have to be included, minor/exotic geographical exceptions, etc.)
JW
2021-08-28 11:04 AM
The STM32 has no way of knowing what timezone it's in unless you provide that information. You add or subtract X hours from the time to convert.
As timezones are complex, arbitrary, and subject to change, this complexity is typically left out of the embedded system.
2021-08-28 11:15 AM
You are right, I was too expecting embedded C function / library to make conversions !
I understand that this is out of context for MCU, but was mentioning to get some examples if it is already done by somebody else.
2021-08-28 01:43 PM
Use the standard C-library functions prototyped in <time. h> to convert the date/time to UNIX epoch-based time, add or subtract the timezone-specific amount, then convert back.
You'll still have to supply the rules,it is application-specific how rigorously have they (mainly DST) be observed (e.g. if historical data have to be included, minor/exotic geographical exceptions, etc.)
JW