Hi,
I am trying to convert Unix epoch time to the one used by MSP430 in CCS V10/TI v20.x.y compiler. Presumably TI compiler uses epoch time starting from 1900-01-01 00:00:00, at least the following code indicate so.
#include "time.h" // Unix epoch time entered via UART console uint32_t unixEpochTime = (bytes[0] << 24) | (bytes[1] << 16) | (bytes[2] << 8) | bytes[3]; unixEpochTime += (uint32_t)2208988800; /*CCS use time since 1900-1-1 00:00:00*/ struct tm* calendarTime = gmtime(&unixEpochTime); uint8_t debugInfo[48]; sprintf(debugInfo, "%04d-%02d-%02d %02d:%02d:%02d, ", calendarTime->tm_year + 1900, calendarTime->tm_mon + 1, calendarTime->tm_mday, calendarTime->tm_hour, calendarTime->tm_min, calendarTime->tm_sec); sendCmdArray((uint8_t *)debugInfo, 21); // Output via UART console
If I enter 0x00000001 for 1 second since epoch or 00000E10 for 1 hour since epoch, I will get following calendar time as expected:
1970-01-01 00:00:01 // 1 second since epoch, as expected 1970-01-01 01:00:00 // 1 hour since epoch, as expected
However, if I enter 0x00015180 for 1 day since epoch, I get an output different from what I expected:
1970-01-01 05:47:44 // It should be 1970-01-02 00:00:00
What am I missing here?
Thanks.