All pastes #487659 Raw Edit

Mine

public text v1 · immutable
·published 2007-05-14 16:05 UTC
rendered paste body
double now()
{
#ifdef WIN32
    FILETIME ft;
    GetSystemTimeAsFileTime(&ft);
    double t = (4294967296.0 * ft.dwHighDateTime + ft.dwLowDateTime);
    /* Converts from 100ns units in 1601 epoch to unix epoch in sec */
    return (t * 1e-7) - 11644473600.0;
#else
    time_t t;
    struct timeval td;
    do { t = time(0); gettimeofday(&td, 0); } while(t != time(0));
    return t + 1e-6 * td.tv_usec;
#endif
}