Dear TI members,
I was trying to convert the UTC time obtained from a remote NTP server to my local time for which I have used the following function code:
void setTime(uint32_t t)
{
time_t ts;
struct tm tm;
struct tm td;
Seconds_set(t);
time(&ts);
tm = *localtime(&ts);
System_printf("NTP Server time: %s\n", asctime(&tm));
System_flush();
}
Here I am getting again the UTC time and the localtime function is not able to convert the UTC time to the local time as the function name suggests.
I tried to get to its root cause so I find that there is a timezone structure inside the time.h header file but it only has the data structure of it and no function to operate on that data structure.
Here is the code snippet from the time.h file of the timezone data structure:
/*************************************************************************/
/* TIME ZONE STRUCTURE DEFINITION */
/*************************************************************************/
typedef struct
{
short daylight;
long timezone; /* seconds WEST of UTC. Strange but traditional */
char tzname[4];
char dstname[4];
} TZ;
extern _DATA_ACCESS TZ _tz;
So , I want to know that how can I use this timezone data structure and how can I make the localtime function to return the local time of my region.
regards