view src/timeconv.c @ 393:ffbb5e3f2551

Add missing linking with zlib and libpthread/librt The uncompress and sem_* functions are used by various parts of the code but the files built from that code were not linked with zlib/pthread/rt. This fixes building with the --no-add-needed linker option. Fixes: https://bugs.debian.org/604796
author Paul Wise <pabs3@bonedaddy.net>
date Mon, 23 Dec 2019 12:23:22 +0800
parents ad7b880ad3d1
children
line wrap: on
line source

#include "define.h"



char* pst_fileTimeToAscii(const FILETIME* filetime, char* result) {
    time_t t;
    t = pst_fileTimeToUnixTime(filetime);
    return ctime_r(&t, result);
}

size_t pst_fileTimeToString(const FILETIME* filetime, const char* date_format, char* result) {
    time_t t;
    t = pst_fileTimeToUnixTime(filetime);
    return strftime(result, MAXDATEFMTLEN-1, date_format, localtime(&t));
}

void pst_fileTimeToStructTM (const FILETIME *filetime, struct tm *result) {
    time_t t1;
    t1 = pst_fileTimeToUnixTime(filetime);
    gmtime_r(&t1, result);
}


time_t pst_fileTimeToUnixTime(const FILETIME *filetime)
{
    uint64_t t = filetime->dwHighDateTime;
    const uint64_t bias = 11644473600LL;
    t <<= 32;
    t += filetime->dwLowDateTime;
    t /= 10000000;
    t -= bias;
    return ((t > (uint64_t)0x000000007fffffff) && (sizeof(time_t) <= 4)) ? 0 : (time_t)t;
}