Updated to use localtime_s() in Windows build environments that support it. Ticket #3126. (CVS 5164)

FossilOrigin-Name: 1518827e48bc3a259b6079a5a4b8dca47b265172
This commit is contained in:
shane 2008-05-27 19:49:21 +00:00
parent 3615b5338b
commit b8109ad375
3 changed files with 36 additions and 8 deletions

View File

@ -1,5 +1,5 @@
C Explicitly\stypedef\sPgno\sas\s'u32'\sinstead\sof\s'unsigned\sint'\sto\sremove\sa\sfew\swarnings/errors\sfrom\snative\sx86_64\scompile.\s(CVS\s5163)
D 2008-05-27T18:11:45
C Updated\sto\suse\slocaltime_s()\sin\sWindows\sbuild\senvironments\sthat\ssupport\sit.\s\sTicket\s#3126.\s(CVS\s5164)
D 2008-05-27T19:49:21
F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7
F Makefile.in 79aeba12300a54903f1b1257c1e7c190234045dd
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@ -102,7 +102,7 @@ F src/btreeInt.h dc04ee33d8eb84714b2acdf81336fbbf6e764530
F src/build.c a52d9d51341444a2131e3431608f245db80d9591
F src/callback.c 77b302b0d41468dcda78c70e706e5b84577f0fa0
F src/complete.c 4cf68fd75d60257524cbe74f87351b9848399131
F src/date.c e41ce4513fb0e359dc678d6bddb4ace135fe365d
F src/date.c b305ced9f4da66b51ef020d9bf31c6c92fc0c6bb
F src/delete.c d3fc5987f2eb88f7b9549d58a5dfea079a83fe8b
F src/expr.c 89f192b22b8c06b61d9b944cb59f42370d80e362
F src/fault.c 1f6177188edb00641673e462f3fab8cba9f7422b
@ -590,7 +590,7 @@ F tool/speedtest16.c 6f5bc019dcf8b6537f379bbac0408a9e1a86f0b6
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c e74126bc12178fa29904f711bb100212a5448041
F tool/speedtest8inst1.c 025879132979a5fdec11218472cba6cf8f6ec854
P 54b84a3ddba9d27814c2f613dd197f691ac549a4
R 355aae5f822bc54cb546f46095fa6fd0
P b5fd8a239d787a126f775101760737781751f56e
R 7cfe648a4ba711ba9a867bf6621bf338
U shane
Z c8e74ab907b84a5ef7d47d703f1cad85
Z b944ae1ffa37a17d40e51075e534325a

View File

@ -1 +1 @@
b5fd8a239d787a126f775101760737781751f56e
1518827e48bc3a259b6079a5a4b8dca47b265172

View File

@ -16,7 +16,7 @@
** sqlite3RegisterDateTimeFunctions() found at the bottom of the file.
** All other code has file scope.
**
** $Id: date.c,v 1.79 2008/03/20 14:03:29 drh Exp $
** $Id: date.c,v 1.80 2008/05/27 19:49:21 shane Exp $
**
** SQLite processes all times and dates as Julian Day numbers. The
** dates and times are stored as the number of days since noon
@ -53,6 +53,23 @@
#ifndef SQLITE_OMIT_DATETIME_FUNCS
/*
** On recent Windows platforms, the localtime_s() function is available
** as part of the "Secure CRT". It is essentially equivalent to
** localtime_r() available under most POSIX platforms, except that the
** order of the parameters is reversed.
**
** See http://msdn.microsoft.com/en-us/library/a442x3ye(VS.80).aspx.
**
** If the user has not indicated to use localtime_r() or localtime_s()
** already, check for an MSVC build environment that provides
** localtime_s().
*/
#if !defined(HAVE_LOCALTIME_R) && !defined(HAVE_LOCALTIME_S) && \
defined(_MSC_VER) && defined(_CRT_INSECURE_DEPRECATE)
#define HAVE_LOCALTIME_S 1
#endif
/*
** A structure for holding a single date and time.
*/
@ -434,6 +451,17 @@ static double localtimeOffset(DateTime *p){
y.m = sLocal.tm_min;
y.s = sLocal.tm_sec;
}
#elif defined(HAVE_LOCALTIME_S)
{
struct tm sLocal;
localtime_s(&sLocal, &t);
y.Y = sLocal.tm_year + 1900;
y.M = sLocal.tm_mon + 1;
y.D = sLocal.tm_mday;
y.h = sLocal.tm_hour;
y.m = sLocal.tm_min;
y.s = sLocal.tm_sec;
}
#else
{
struct tm *pTm;