/ Check-in [12f3ba11]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add the ability to disable the "localtime" modifier in the date/time functions. This might be necessary for systems that do not support localtime_r() or localtime_s(). (CVS 5212)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 12f3ba11e72b2310abf51d040d5344c81fe5ebd3
User & Date: drh 2008-06-12 12:51:37
Context
2008-06-12
13:50
Avoid unnecessary float->text->float conversions in date/time processing. This change necessary to reproduce the problem reported by BareFoot. (CVS 5213) check-in: 6ec4d765 user: drh tags: trunk
12:51
Add the ability to disable the "localtime" modifier in the date/time functions. This might be necessary for systems that do not support localtime_r() or localtime_s(). (CVS 5212) check-in: 12f3ba11 user: drh tags: trunk
12:40
Remove obsolete code from the test_osinst.c module. (CVS 5211) check-in: 699cec66 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/date.c.

    12     12   ** This file contains the C functions that implement date and time
    13     13   ** functions for SQLite.  
    14     14   **
    15     15   ** There is only one exported symbol in this file - the function
    16     16   ** sqlite3RegisterDateTimeFunctions() found at the bottom of the file.
    17     17   ** All other code has file scope.
    18     18   **
    19         -** $Id: date.c,v 1.80 2008/05/27 19:49:21 shane Exp $
           19  +** $Id: date.c,v 1.81 2008/06/12 12:51:37 drh Exp $
    20     20   **
    21     21   ** SQLite processes all times and dates as Julian Day numbers.  The
    22     22   ** dates and times are stored as the number of days since noon
    23     23   ** in Greenwich on November 24, 4714 B.C. according to the Gregorian
    24     24   ** calendar system. 
    25     25   **
    26     26   ** 1970-01-01 00:00:00 is JD 2440587.5
................................................................................
   412    412   */
   413    413   static void clearYMD_HMS_TZ(DateTime *p){
   414    414     p->validYMD = 0;
   415    415     p->validHMS = 0;
   416    416     p->validTZ = 0;
   417    417   }
   418    418   
          419  +#ifndef SQLITE_OMIT_LOCALTIME
   419    420   /*
   420    421   ** Compute the difference (in days) between localtime and UTC (a.k.a. GMT)
   421    422   ** for the time value p where p is in UTC.
   422    423   */
   423    424   static double localtimeOffset(DateTime *p){
   424    425     DateTime x, y;
   425    426     time_t t;
................................................................................
   479    480     y.validYMD = 1;
   480    481     y.validHMS = 1;
   481    482     y.validJD = 0;
   482    483     y.validTZ = 0;
   483    484     computeJD(&y);
   484    485     return y.rJD - x.rJD;
   485    486   }
          487  +#endif /* SQLITE_OMIT_LOCALTIME */
   486    488   
   487    489   /*
   488    490   ** Process a modifier to a date-time stamp.  The modifiers are
   489    491   ** as follows:
   490    492   **
   491    493   **     NNN days
   492    494   **     NNN hours
................................................................................
   512    514     char *z, zBuf[30];
   513    515     z = zBuf;
   514    516     for(n=0; n<sizeof(zBuf)-1 && zMod[n]; n++){
   515    517       z[n] = tolower(zMod[n]);
   516    518     }
   517    519     z[n] = 0;
   518    520     switch( z[0] ){
          521  +#ifndef SQLITE_OMIT_LOCALTIME
   519    522       case 'l': {
   520    523         /*    localtime
   521    524         **
   522    525         ** Assuming the current time value is UTC (a.k.a. GMT), shift it to
   523    526         ** show local time.
   524    527         */
   525    528         if( strcmp(z, "localtime")==0 ){
................................................................................
   526    529           computeJD(p);
   527    530           p->rJD += localtimeOffset(p);
   528    531           clearYMD_HMS_TZ(p);
   529    532           rc = 0;
   530    533         }
   531    534         break;
   532    535       }
          536  +#endif
   533    537       case 'u': {
   534    538         /*
   535    539         **    unixepoch
   536    540         **
   537    541         ** Treat the current value of p->rJD as the number of
   538    542         ** seconds since 1970.  Convert to a real julian day number.
   539    543         */

Changes to src/test_config.c.

    12     12   ** 
    13     13   ** This file contains code used for testing the SQLite system.
    14     14   ** None of the code in this file goes into a deliverable build.
    15     15   ** 
    16     16   ** The focus of this file is providing the TCL testing layer
    17     17   ** access to compile-time constants.
    18     18   **
    19         -** $Id: test_config.c,v 1.26 2008/05/26 18:41:54 danielk1977 Exp $
           19  +** $Id: test_config.c,v 1.27 2008/06/12 12:51:37 drh Exp $
    20     20   */
    21     21   
    22     22   #include "sqliteLimit.h"
    23     23   
    24     24   #include "sqliteInt.h"
    25     25   #include "tcl.h"
    26     26   #include <stdlib.h>
................................................................................
   280    280   #endif
   281    281   
   282    282   #ifdef SQLITE_OMIT_LOAD_EXTENSION
   283    283     Tcl_SetVar2(interp, "sqlite_options", "load_ext", "0", TCL_GLOBAL_ONLY);
   284    284   #else
   285    285     Tcl_SetVar2(interp, "sqlite_options", "load_ext", "1", TCL_GLOBAL_ONLY);
   286    286   #endif
          287  +
          288  +#ifdef SQLITE_OMIT_LOCALTIME
          289  +  Tcl_SetVar2(interp, "sqlite_options", "localtime", "0", TCL_GLOBAL_ONLY);
          290  +#else
          291  +  Tcl_SetVar2(interp, "sqlite_options", "localtime", "1", TCL_GLOBAL_ONLY);
          292  +#endif
   287    293   
   288    294   Tcl_SetVar2(interp, "sqlite_options", "long_double",
   289    295                 sizeof(LONGDOUBLE_TYPE)>sizeof(double) ? "1" : "0",
   290    296                 TCL_GLOBAL_ONLY);
   291    297   
   292    298   #ifdef SQLITE_OMIT_MEMORYDB
   293    299     Tcl_SetVar2(interp, "sqlite_options", "memorydb", "0", TCL_GLOBAL_ONLY);