view src/timeconv.c @ 195:320cfcba8058

add python module interface to the shared library for easy scripting. the shared library must never write to stdout or stderr. fix pst_attach_to_mem so the caller does not need to initialize the buffer pointer.
author Carl Byington <carl@five-ten-sg.com>
date Mon, 20 Apr 2009 19:39:26 -0700
parents b65e8d0a088a
children 7c60d6d1c681
line wrap: on
line source

#include "define.h"



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


struct tm * pst_fileTimeToStructTM (const FILETIME *filetime) {
    time_t t1;
    t1 = pst_fileTimeToUnixTime(filetime);
    return gmtime(&t1);
}


time_t pst_fileTimeToUnixTime(const FILETIME *filetime)
{
    int64_t t = filetime->dwHighDateTime;
    t <<= 32;
    t += filetime->dwLowDateTime;
    t -= 116444736000000000LL;
    if (t < 0) {
        return -1 - ((-t - 1) / 10000000);
    }
    else {
        return t / 10000000;
    }
}