From f11c34df74582004f56e710791b2d7e40081ca54 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 8 Sep 2006 12:27:36 +0000 Subject: [PATCH] Bug fix in date/time computations. Ticket #1964. Some unrelated comment typos are also fixed and got accidently checked in at the same time. (CVS 3396) FossilOrigin-Name: c81eaa0dc9a327d222e066076c4a2da5e69d8c21 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/alter.c | 8 ++++---- src/date.c | 7 ++++--- test/date.test | 7 ++++--- 5 files changed, 21 insertions(+), 19 deletions(-) diff --git a/manifest b/manifest index 253e4df573..431b85fd3d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improvements\sto\sthe\sdocumentation\sof\sthe\sreturn\scodes\sfor\ssqlite3_step().\nTickets\s#1633,\s#1366,\s#1178,\s#906,\sand\sprobably\sothers\stoo.\s(CVS\s3395) -D 2006-09-08T11:56:30 +C Bug\sfix\sin\sdate/time\scomputations.\s\sTicket\s#1964.\r\nSome\sunrelated\scomment\stypos\sare\salso\sfixed\sand\sgot\saccidently\r\nchecked\sin\sat\sthe\ssame\stime.\s(CVS\s3396) +D 2006-09-08T12:27:37 F Makefile.in cabd42d34340f49260bc2a7668c38eba8d4cfd99 F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028 @@ -44,7 +44,7 @@ F sqlite.pc.in 30552343140c53304c2a658c080fbe810cd09ca2 F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc F sqlite3.def a96c1d0d39362b763d2ddba220a32da41a15c4b4 F sqlite3.pc.in 985b9bf34192a549d7d370e0f0b6b34a4f61369a -F src/alter.c eba661e77bfd00282fbfa316cdb6aef04856fedc +F src/alter.c 2c79ec40f65e33deaf90ca493422c74586e481a3 F src/analyze.c 7d2b7ab9a9c2fd6e55700f69064dfdd3e36d7a8a F src/attach.c b11eb4d5d3fb99a10a626956bccc7215f6b68b16 F src/auth.c 902f4722661c796b97f007d9606bd7529c02597f @@ -53,7 +53,7 @@ F src/btree.h 061c50e37de7f50b58528e352d400cf33ead7418 F src/build.c 4359b34a36938716ed10ac037eec9dc5173b8f4b F src/callback.c fd9bb39f7ff6b52bad8365617abc61c720640429 F src/complete.c 7d1a44be8f37de125fcafd3d3a018690b3799675 -F src/date.c cd2bd5d1ebc6fa12d6312f69789ae5b0a2766f2e +F src/date.c bbfc2db2b713193f08bc482c27961a801fce6671 F src/delete.c 804384761144fe1a5035b99f4bd7d706976831bd F src/experimental.c 1b2d1a6cd62ecc39610e97670332ca073c50792b F src/expr.c 0546cc60f08c426d96092dea0789d085aed3580e @@ -174,7 +174,7 @@ F test/corrupt.test 18c7a995b1af76a8c8600b996257f2c7b7bff083 F test/corrupt2.test 88342570828f2b8cbbd8369eff3891f5c0bdd5ba F test/crash.test 5f5f155393c5685b3842fef79b6fbafa55197d75 F test/crashtest1.c 09c1c7d728ccf4feb9e481671e29dda5669bbcc2 -F test/date.test fa6cc4e5fb79a207f77b66a51d2b3244ac76feae +F test/date.test 0f39a64f8f05c269b8568a8cbf3855d49359d328 F test/default.test 252298e42a680146b1dd64f563b95bdf088d94fb F test/delete.test 525a6953bc3978780cae35f3eaf1027cf4ce887d F test/delete2.test c06be3806ba804bc8c6f134476816080280b40e3 @@ -396,7 +396,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513 -P b3eb1732bd529b14bef1872171a3c6429e209d31 -R e34c4ab5b751389f6c05ea187f495fb0 +P 508248e783dc1e3da3695b28467ca3b79629e582 +R db789daf8e27e8308536c276b6e1da10 U drh -Z f62f8cbf6340cbbbc58aed5f40a05996 +Z c96944e52a68f5437f07b5ef49e8020c diff --git a/manifest.uuid b/manifest.uuid index 3e0f444609..af8ed8de63 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -508248e783dc1e3da3695b28467ca3b79629e582 \ No newline at end of file +c81eaa0dc9a327d222e066076c4a2da5e69d8c21 \ No newline at end of file diff --git a/src/alter.c b/src/alter.c index efab598ed8..128f3d6611 100644 --- a/src/alter.c +++ b/src/alter.c @@ -12,7 +12,7 @@ ** This file contains C code routines that used to generate VDBE code ** that implements the ALTER TABLE command. ** -** $Id: alter.c,v 1.21 2006/06/21 12:36:25 danielk1977 Exp $ +** $Id: alter.c,v 1.22 2006/09/08 12:27:37 drh Exp $ */ #include "sqliteInt.h" #include @@ -28,7 +28,7 @@ ** This function is used by SQL generated to implement the ** ALTER TABLE command. The first argument is the text of a CREATE TABLE or ** CREATE INDEX command. The second is a table name. The table name in -** the CREATE TABLE or CREATE INDEX statement is replaced with the second +** the CREATE TABLE or CREATE INDEX statement is replaced with the third ** argument and the result returned. Examples: ** ** sqlite_rename_table('CREATE TABLE abc(a, b, c)', 'def') @@ -78,10 +78,10 @@ static void renameTableFunc( } #ifndef SQLITE_OMIT_TRIGGER -/* This function is used by SQL generated to implement the ALTER TABLE +/* This function is used by SQL generated to implement the ** ALTER TABLE command. The first argument is the text of a CREATE TRIGGER ** statement. The second is a table name. The table name in the CREATE -** TRIGGER statement is replaced with the second argument and the result +** TRIGGER statement is replaced with the third argument and the result ** returned. This is analagous to renameTableFunc() above, except for CREATE ** TRIGGER, not CREATE INDEX and CREATE TABLE. */ diff --git a/src/date.c b/src/date.c index 8188f26090..1af6fa43fe 100644 --- a/src/date.c +++ b/src/date.c @@ -16,7 +16,7 @@ ** sqlite3RegisterDateTimeFunctions() found at the bottom of the file. ** All other code has file scope. ** -** $Id: date.c,v 1.54 2006/01/31 20:49:13 drh Exp $ +** $Id: date.c,v 1.55 2006/09/08 12:27:37 drh Exp $ ** ** NOTES: ** @@ -234,11 +234,11 @@ static void computeJD(DateTime *p){ X2 = 30.6001*(M+1); p->rJD = X1 + X2 + D + B - 1524.5; p->validJD = 1; - p->validYMD = 0; if( p->validHMS ){ p->rJD += (p->h*3600.0 + p->m*60.0 + p->s)/86400.0; if( p->validTZ ){ p->rJD -= p->tz*60/86400.0; + p->validYMD = 0; p->validHMS = 0; p->validTZ = 0; } @@ -357,6 +357,7 @@ static void computeYMD(DateTime *p){ static void computeHMS(DateTime *p){ int Z, s; if( p->validHMS ) return; + computeJD(p); Z = p->rJD + 0.5; s = (p->rJD + 0.5 - Z)*86400000.0 + 0.5; p->s = 0.001*s; @@ -581,7 +582,7 @@ static int parseModifier(const char *zMod, DateTime *p){ if( z[0]=='-' ) tx.rJD = -tx.rJD; computeJD(p); clearYMD_HMS_TZ(p); - p->rJD += tx.rJD; + p->rJD += tx.rJD; rc = 0; break; } diff --git a/test/date.test b/test/date.test index 516ea67d26..d05722d164 100644 --- a/test/date.test +++ b/test/date.test @@ -11,7 +11,7 @@ # This file implements regression tests for SQLite library. The # focus of this file is testing date and time functions. # -# $Id: date.test,v 1.15 2006/09/01 15:49:06 drh Exp $ +# $Id: date.test,v 1.16 2006/09/08 12:27:37 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -273,7 +273,8 @@ datetest 11.9 {datetime('2004-02-28 20:00:00', '12:01')} \ {2004-02-29 08:01:00} datetest 11.10 {datetime('2004-02-28 20:00:00', '12:60')} NULL - - +# Ticket #1964 +datetest 12.1 {datetime('2005-09-01')} {2005-09-01 00:00:00} +datetest 12.2 {datetime('2005-09-01','+0 hours')} {2005-09-01 00:00:00} finish_test