view src/timeconv.c @ 185:e0392999e9b8

Added tag stable-0-6-36 for changeset 05dc6892d7e4
author Carl Byington <carl@five-ten-sg.com>
date Mon, 13 Apr 2009 15:55:55 -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;
    }
}