My C is a little rusty, but looking at the other two answers, I will write the function as follows, returning the number of seconds from an era or -1 in case of an error.
#include <stdio.h>
#include <time.h>
time_t convertDecimalTime(long dt) {
struct tm time_str;
time_str.tm_isdst = -1;
time_str.tm_sec = dt%100; dt/=100;
time_str.tm_min = dt%100; dt/=100;
time_str.tm_hour = dt%100; dt/=100;
time_str.tm_mday = dt%100; dt/=100;
time_str.tm_mon = dt%100-1; dt/=100;
time_str.tm_year = dt%10000 - 1900;
return mktime(&time_str);
}
source
share