/ Check-in [e853067e]
Login

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

Overview
Comment:Make sure the strftime() date conversions put in leading zeros correctly. Ticket #2276. (CVS 3749)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: e853067ec4db3eedfb4adcdd4172de2c55b9ac58
User & Date: drh 2007-03-29 17:57:21
Context
2007-03-29
18:19
Change the name of PAGER_SECTOR_SIZE to SQLITE_DEFAULT_SECTOR_SIZE. Make the new OS-layer interface routine for finding sector size optional. (CVS 3750) check-in: 0fb9af1d user: drh tags: trunk
17:57
Make sure the strftime() date conversions put in leading zeros correctly. Ticket #2276. (CVS 3749) check-in: e853067e user: drh tags: trunk
17:28
Avoid calling OsDelete() on journal files when they are opened for temporary databases. Fix for #2255. (CVS 3748) check-in: e746832f user: danielk1977 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.60 2007/01/08 16:19:07 drh Exp $
           19  +** $Id: date.c,v 1.61 2007/03/29 17:57:21 drh Exp $
    20     20   **
    21     21   ** NOTES:
    22     22   **
    23     23   ** SQLite processes all times and dates as Julian Day numbers.  The
    24     24   ** dates and times are stored as the number of days since noon
    25     25   ** in Greenwich on November 24, 4714 B.C. according to the Gregorian
    26     26   ** calendar system. 
................................................................................
   823    823       }else{
   824    824         i++;
   825    825         switch( zFmt[i] ){
   826    826           case 'd':  sprintf(&z[j],"%02d",x.D); j+=2; break;
   827    827           case 'f': {
   828    828             double s = x.s;
   829    829             if( s>59.999 ) s = 59.999;
   830         -          sqlite3_snprintf(7, &z[j],"%02.3f", s);
          830  +          sqlite3_snprintf(7, &z[j],"%06.3f", s);
   831    831             j += strlen(&z[j]);
   832    832             break;
   833    833           }
   834    834           case 'H':  sprintf(&z[j],"%02d",x.h); j+=2; break;
   835    835           case 'W': /* Fall thru */
   836    836           case 'j': {
   837    837             int nDay;             /* Number of days since 1st day of year */

Changes to test/date.test.

     7      7   #    May you find forgiveness for yourself and forgive others.
     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this file is testing date and time functions.
    13     13   #
    14         -# $Id: date.test,v 1.19 2007/01/08 16:19:07 drh Exp $
           14  +# $Id: date.test,v 1.20 2007/03/29 17:57:21 drh Exp $
    15     15   
    16     16   set testdir [file dirname $argv0]
    17     17   source $testdir/tester.tcl
    18     18   
    19     19   # Skip this whole file if date and time functions are omitted
    20     20   # at compile-time
    21     21   #
................................................................................
   145    145       incr n -1
   146    146     }
   147    147     return $x
   148    148   }
   149    149   datetest 3.16 "strftime('[repeat 200 %Y]','2003-10-31')" [repeat 200 2003]
   150    150   datetest 3.17 "strftime('[repeat 200 abc%m123]','2003-10-31')" \
   151    151       [repeat 200 abc10123]
          152  +
          153  +# Ticket #2276.  Make sure leading zeros are inserted where appropriate.
          154  +#
          155  +datetest 3.20 \
          156  +   {strftime('%d/%f/%H/%W/%j/%m/%M/%S/%Y','0421-01-02 03:04:05.006')} \
          157  +   02/05.006/03/00/002/01/04/05/0421
   152    158   
   153    159   set sqlite_current_time 1157124367
   154    160   datetest 4.1 {date('now')} {2006-09-01}
   155    161   set sqlite_current_time 0
   156    162   
   157    163   datetest 5.1 {datetime('1994-04-16 14:00:00 +05:00')} {1994-04-16 09:00:00}
   158    164   datetest 5.2 {datetime('1994-04-16 14:00:00 -05:15')} {1994-04-16 19:15:00}