Make sure the 'unixepoch' converter in the date and time functions rounds

to the nearest millisecond rather than truncating downward to the next
smaller millisecond.  Ticket #3808. (CVS 6512)

FossilOrigin-Name: e6e036b345b130c207716c4b81719b5b7c884a11
This commit is contained in:
drh 2009-04-16 12:58:03 +00:00
parent 10c081adf8
commit 7fee360d09
4 changed files with 16 additions and 11 deletions

View File

@ -1,5 +1,5 @@
C In\sa\s3-fold\scompound\sSELECT\smake\ssure\searly\scode\sgeneration\sof\sthe\sSELECTs\nto\sthe\sright\sdo\snot\sdereference\snon-existant\scolumns\sin\sSELECTs\son\sthe\sleft.\s(CVS\s6511)
D 2009-04-16T00:24:24
C Make\ssure\sthe\s'unixepoch'\sconverter\sin\sthe\sdate\sand\stime\sfunctions\srounds\nto\sthe\snearest\smillisecond\srather\sthan\struncating\sdownward\sto\sthe\snext\nsmaller\smillisecond.\s\sTicket\s#3808.\s(CVS\s6512)
D 2009-04-16T12:58:03
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in 583e87706abc3026960ed759aff6371faf84c211
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@ -109,7 +109,7 @@ F src/btreeInt.h df64030d632f8c8ac217ed52e8b6b3eacacb33a5
F src/build.c 2882f22078db1c3f887b1aca77ff460cf9461c62
F src/callback.c 73016376d6848ba987709e8c9048d4f0e0776036
F src/complete.c cb14e06dbe79dee031031f0d9e686ff306afe07c
F src/date.c 3e5c554b2f4f2d798761597c08147d7b15f35bea
F src/date.c d327ec7bb2f64b08d32b1035de82b9ba8675de91
F src/delete.c eb1066b2f35489fee46ad765d2b66386fc7d8adf
F src/expr.c ccc5b5fa3bac249a9ab6e5e10629d77ff293c9f8
F src/fault.c dc88c821842157460750d2d61a8a8b4197d047ff
@ -299,7 +299,7 @@ F test/crash8.test 5b32966fcb58fd616d24ce94303420351d076eb9
F test/crashtest1.c 09c1c7d728ccf4feb9e481671e29dda5669bbcc2
F test/createtab.test 199cf68f44e5d9e87a0b8afc7130fdeb4def3272
F test/cse.test 277350a26264495e86b1785f34d2d0c8600e021c
F test/date.test 95a5611a677f639742db4d7c13af99c2ff56e299
F test/date.test 0b8473ed9ab6fd4283b4a01f035e1067762ba734
F test/default.test 6faf23ccb300114924353007795aa9a8ec0aa9dc
F test/delete.test 2b33a092350ab09f38e04522675ad761ce069358
F test/delete2.test 3a03f2cca1f9a67ec469915cb8babd6485db43fa
@ -717,7 +717,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
P b83fbf15a3920755ed77dc9c91b4f00a86ddb9ac
R 1b07912c8c6ff40738cf08bdcff2243f
P 414f340809c487901fa913026a342b19a2956c0a
R 36b9ab0b0c871b31105f30d21ff665d4
U drh
Z 5dd358d6f1180bed564e211b297b0523
Z 2bce441c175c79c6663221930da841a4

View File

@ -1 +1 @@
414f340809c487901fa913026a342b19a2956c0a
e6e036b345b130c207716c4b81719b5b7c884a11

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.105 2009/04/03 12:04:37 drh Exp $
** $Id: date.c,v 1.106 2009/04/16 12:58:03 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
@ -549,7 +549,7 @@ static int parseModifier(const char *zMod, DateTime *p){
** seconds since 1970. Convert to a real julian day number.
*/
if( strcmp(z, "unixepoch")==0 && p->validJD ){
p->iJD = p->iJD/86400 + 21086676*(i64)10000000;
p->iJD = (p->iJD + 43200)/86400 + 21086676*(i64)10000000;
clearYMD_HMS_TZ(p);
rc = 0;
}

View File

@ -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.33 2009/04/01 20:44:14 drh Exp $
# $Id: date.test,v 1.34 2009/04/16 12:58:03 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -71,6 +71,11 @@ datetest 2.1c datetime(0,'unixepochx') NULL
datetest 2.1d datetime('2003-10-22','unixepoch') NULL
datetest 2.2 datetime(946684800,'unixepoch') {2000-01-01 00:00:00}
datetest 2.2b datetime('946684800','unixepoch') {2000-01-01 00:00:00}
for {set i 0} {$i<1000} {incr i} {
set sql [format {strftime('%%H:%%M:%%f',1237962480.%03d,'unixepoch')} $i]
set res [format {06:28:00.%03d} $i]
datetest 2.2c-$i $sql $res
}
datetest 2.3 {date('2003-10-22','weekday 0')} 2003-10-26
datetest 2.4 {date('2003-10-22','weekday 1')} 2003-10-27
datetest 2.4a {date('2003-10-22','weekday 1')} 2003-10-27