I would like to propose this version of winCurrentTime() which generates the
same results as the current implementation but much simpler:
int winCurrentTime(sqlite3_vfs *pVfs, double *prNow) {
FILETIME ft;
ULARGE_INTEGER ft64;
#if SQLITE_OS_WINCE
SYSTEMTIME time;
GetSystemTime(&time);
/* if SystemTimeToFileTime() fails, it returns zero. */
if (!SystemTimeToFileTime(&time,&ft)) {
return 1;
}
#else
GetSystemTimeAsFileTime(&ft);
#endif
UNUSED_PARAMETER(pVfs);
/* FILETIME structure is an unsigned 64-bit value representing the number of
100-nanosecond intervals since January 1, 1601 (= JD 2305813.5).
10000000*86400=(2^14)*(5^9)*(3^3)
will need to add 2305813.5 to get Julian day.
Will use 2^13 so that (2*2305813.5)=4611627
can be added in before float computation.
Summary:
Divide by 2^13 i.e. shift right 2^13
Add Julian offset 4611627*(5^9)*(3^3) = 0x0DD2E611DD10D
Divide by remaining factors 2*(5^9)*(3^3) = 105468750
*/
ft64.u.LowPart = ft.dwLowDateTime;
ft64.u.HighPart= ft.dwHighDateTime;
*prNow = ((ft64.QuadPart>>13) + 0x0DD2E611DD10DL) / 105468750.0L;
return 0;
}
4eanlss
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users