Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Avoid unnecessary float->text->float conversions in date/time processing. This change necessary to reproduce the problem reported by BareFoot. (CVS 5213) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
6ec4d7653b1e67ba0951e909ee23fe77 |
User & Date: | drh 2008-06-12 13:50:00.000 |
Context
2008-06-12
| ||
14:42 | Add another test to incrblob2.test. This test failed to reveal any new bugs. (CVS 5214) (check-in: 20d8ea45af user: danielk1977 tags: trunk) | |
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: 6ec4d7653b 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: 12f3ba11e7 user: drh tags: trunk) | |
Changes
Changes to src/date.c.
︙ | ︙ | |||
12 13 14 15 16 17 18 | ** This file contains the C functions that implement date and time ** functions for SQLite. ** ** There is only one exported symbol in this file - the function ** sqlite3RegisterDateTimeFunctions() found at the bottom of the file. ** All other code has file scope. ** | | | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | ** This file contains the C functions that implement date and time ** functions for SQLite. ** ** There is only one exported symbol in this file - the function ** sqlite3RegisterDateTimeFunctions() found at the bottom of the file. ** All other code has file scope. ** ** $Id: date.c,v 1.82 2008/06/12 13:50:00 drh Exp $ ** ** SQLite processes all times and dates as Julian Day numbers. The ** dates and times are stored as the number of days since noon ** in Greenwich on November 24, 4714 B.C. according to the Gregorian ** calendar system. ** ** 1970-01-01 00:00:00 is JD 2440587.5 |
︙ | ︙ | |||
308 309 310 311 312 313 314 315 316 317 318 319 320 321 | p->M = M; p->D = D; if( p->validTZ ){ computeJD(p); } return 0; } /* ** Attempt to parse the given string into a Julian Day Number. Return ** the number of errors. ** ** The following are acceptable forms for the input string: ** | > > > > > > > > > > > | 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 | p->M = M; p->D = D; if( p->validTZ ){ computeJD(p); } return 0; } /* ** Set the time to the current time reported by the VFS */ static void setDateTimeToCurrent(sqlite3_context *context, DateTime *p){ double r; sqlite3 *db = sqlite3_context_db_handle(context); sqlite3OsCurrentTime(db->pVfs, &r); p->rJD = r; p->validJD = 1; } /* ** Attempt to parse the given string into a Julian Day Number. Return ** the number of errors. ** ** The following are acceptable forms for the input string: ** |
︙ | ︙ | |||
336 337 338 339 340 341 342 | ){ memset(p, 0, sizeof(*p)); if( parseYyyyMmDd(zDate,p)==0 ){ return 0; }else if( parseHhMmSs(zDate, p)==0 ){ return 0; }else if( sqlite3StrICmp(zDate,"now")==0){ | < < | < < | 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 | ){ memset(p, 0, sizeof(*p)); if( parseYyyyMmDd(zDate,p)==0 ){ return 0; }else if( parseHhMmSs(zDate, p)==0 ){ return 0; }else if( sqlite3StrICmp(zDate,"now")==0){ setDateTimeToCurrent(context, p); return 0; }else if( sqlite3IsNumber(zDate, 0, SQLITE_UTF8) ){ getValue(zDate, &p->rJD); p->validJD = 1; return 0; } return 1; |
︙ | ︙ | |||
704 705 706 707 708 709 710 | sqlite3_context *context, int argc, sqlite3_value **argv, DateTime *p ){ int i; const unsigned char *z; | | > > > > | < | | > | 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 | sqlite3_context *context, int argc, sqlite3_value **argv, DateTime *p ){ int i; const unsigned char *z; memset(p, 0, sizeof(*p)); if( argc==0 ){ setDateTimeToCurrent(context, p); }else if( sqlite3_value_type(argv[0])==SQLITE_FLOAT ){ memset(p, 0, sizeof(*p)); p->rJD = sqlite3_value_double(argv[0]); p->validJD = 1; }else{ z = sqlite3_value_text(argv[0]); if( !z || parseDateOrTime(context, (char*)z, p) ){ return 1; } } for(i=1; i<argc; i++){ if( (z = sqlite3_value_text(argv[i]))==0 || parseModifier((char*)z, p) ){ return 1; } } return 0; |
︙ | ︙ |