Use gmtime().
Just divide the number of marks to get integer numbers of seconds, and add an offset to change the era from January 1, 2014 to January 1, 1970.
void print_time(unsigned long long tick_count) {
static const unsigned long ticks_per_sec = 100000000L;
static const time_t epoch_delta = 16071L*24*60*60;
time_t seconds = tick_count/ticks_per_sec + epoch_delta;
unsigned long fraction = tick_count%ticks_per_sec;
struct tm tm = *gmtime(&seconds);
printf("%4d-%02d-%02d %02d:%02d:%02d.%03lu\n",
tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday,
tm.tm_hour, tm.tm_min, tm.tm_sec,
fraction/10000);
}
[After Accept Edit]
OP: " time.h, , 1970 , "
- mktime(). , @DavidEisenstat. tm_sec, int (, 32 ), 2014-282. mktime() . tm_sec 16-, tm_mday, tm_hour, tm_min, tm_sec.
void print_time2(unsigned long long tick_count) {
static const unsigned long ticks_per_sec = 100000000L;
unsigned long fraction = tick_count%ticks_per_sec;
unsigned long long secondsFromJan12014 = tick_count/ticks_per_sec;
struct tm tm = {0};
tm.tm_year = 2014 - 1900;
tm.tm_mday = 1;
tm.tm_sec = secondsFromJan12014;
if (mktime(&tm) == (time_t)(-1)) Handle_Failure();
printf("%4d-%02d-%02d %02d:%02d:%02d.%03lu\n",
tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday,
tm.tm_hour, tm.tm_min, tm.tm_sec,
fraction/10000);
}