1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-05 15:55:57 +03:00

Add the sqlite_current_time variable for testing purposes. (CVS 1156)

FossilOrigin-Name: 23fa407d50741bc0719259792398f28c1d0f12c2
This commit is contained in:
drh
2004-01-06 00:44:24 +00:00
parent b46d162d8d
commit e807febbc2
4 changed files with 25 additions and 12 deletions

View File

@@ -1616,6 +1616,14 @@ char *sqliteOsFullPathname(const char *zRelative){
#endif
}
/*
** The following variable, if set to a now-zero value, become the result
** returned from sqliteOsCurrentTime(). This is used for testing.
*/
#ifdef SQLITE_TEST
int sqlite_current_time = 0;
#endif
/*
** Find the current time (in Universal Coordinated Time). Write the
** current time and date as a Julian Day number into *prNow and
@@ -1626,7 +1634,6 @@ int sqliteOsCurrentTime(double *prNow){
time_t t;
time(&t);
*prNow = t/86400.0 + 2440587.5;
return 0;
#endif
#if OS_WIN
FILETIME ft;
@@ -1637,8 +1644,11 @@ int sqliteOsCurrentTime(double *prNow){
GetSystemTimeAsFileTime( &ft );
now = ((double)ft.dwHighDateTime) * 4294967296.0;
*prNow = (now + ft.dwLowDateTime)/864000000000.0 + 2305813.5;
#endif
#ifdef SQLITE_TEST
if( sqlite_current_time ){
*prNow = sqlite_current_time/86400.0 + 2440587.5;
}
#endif
return 0;
return 1;
}