Fix the strftime() function so that the %s format can handle dates outside

of the range of 1901 to 2038.  Ticket #3769. (CVS 6430)

FossilOrigin-Name: a95b843a9251ca9f9a23e8b67c2126f4c297a534
This commit is contained in:
drh 2009-04-01 20:44:13 +00:00
parent 4b2b8b705d
commit 6eb41523f1
4 changed files with 21 additions and 13 deletions

View File

@ -1,5 +1,5 @@
C Change\san\sunreachable\serror\scondition\stest\sto\san\sassert()\sin\srowset.c.\s(CVS\s6429)
D 2009-04-01T19:35:55
C Fix\sthe\sstrftime()\sfunction\sso\sthat\sthe\s%s\sformat\scan\shandle\sdates\soutside\nof\sthe\srange\sof\s1901\sto\s2038.\s\sTicket\s#3769.\s(CVS\s6430)
D 2009-04-01T20:44:14
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 72357fd75ef036d0afbf1756edab6d62c56fcf4b
F src/callback.c 73016376d6848ba987709e8c9048d4f0e0776036
F src/complete.c cb14e06dbe79dee031031f0d9e686ff306afe07c
F src/date.c 0d804df3bbda46329946a01ff5c75c3f4f135218
F src/date.c e6263ed8950642f593cb1a2cc8a73dd726cc7888
F src/delete.c eb1066b2f35489fee46ad765d2b66386fc7d8adf
F src/expr.c 14853cd56107292de6af664a24c6255111a4257d
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 bb2cc648333c04d09e8e23cfc0cddc398c334a92
F test/date.test 95a5611a677f639742db4d7c13af99c2ff56e299
F test/default.test 6faf23ccb300114924353007795aa9a8ec0aa9dc
F test/delete.test f171c1011395a8dd63169438fe1d8cc625eb7442
F test/delete2.test 3a03f2cca1f9a67ec469915cb8babd6485db43fa
@ -714,7 +714,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
P 859792958b4d4a3623d68526ff773f778bdf3f0d
R ee5893a284b1dfffd70d7e1715a343a4
P 36115e4073528f03253dd94fadf3954522c0dfb9
R 00a8b22d9cb1f0d232f45571019310a5
U drh
Z 76cdfb7f19847a2c25df1f69a8945188
Z 410f6e88d081a33d059402dd6e5bba76

View File

@ -1 +1 @@
36115e4073528f03253dd94fadf3954522c0dfb9
a95b843a9251ca9f9a23e8b67c2126f4c297a534

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.103 2009/02/04 03:59:25 shane Exp $
** $Id: date.c,v 1.104 2009/04/01 20:44:14 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
@ -953,8 +953,8 @@ static void strftimeFunc(
case 'm': sqlite3_snprintf(3, &z[j],"%02d",x.M); j+=2; break;
case 'M': sqlite3_snprintf(3, &z[j],"%02d",x.m); j+=2; break;
case 's': {
sqlite3_snprintf(30,&z[j],"%d",
(int)(x.iJD/1000.0 - 210866760000.0));
sqlite3_snprintf(30,&z[j],"%lld",
(i64)(x.iJD/1000.0 - 210866760000.0));
j += sqlite3Strlen30(&z[j]);
break;
}

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.32 2009/01/30 17:27:44 drh Exp $
# $Id: date.test,v 1.33 2009/04/01 20:44:14 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -144,7 +144,15 @@ datetest 3.4 {strftime('%j','2003-10-31 12:34:56.432')} 304
datetest 3.5 {strftime('%J','2003-10-31 12:34:56.432')} 2452944.02426426
datetest 3.6 {strftime('%m','2003-10-31 12:34:56.432')} 10
datetest 3.7 {strftime('%M','2003-10-31 12:34:56.432')} 34
datetest 3.8 {strftime('%s','2003-10-31 12:34:56.432')} 1067603696
datetest 3.8.1 {strftime('%s','2003-10-31 12:34:56.432')} 1067603696
datetest 3.8.2 {strftime('%s','2038-01-19 03:14:07')} 2147483647
datetest 3.8.3 {strftime('%s','2038-01-19 03:14:08')} 2147483648
datetest 3.8.4 {strftime('%s','2201-04-09 12:00:00')} 7298164800
datetest 3.8.5 {strftime('%s','9999-12-31 23:59:59')} 253402300799
datetest 3.8.6 {strftime('%s','1969-12-31 23:59:59')} -1
datetest 3.8.7 {strftime('%s','1901-12-13 20:45:52')} -2147483648
datetest 3.8.8 {strftime('%s','1901-12-13 20:45:51')} -2147483649
datetest 3.8.9 {strftime('%s','1776-07-04 00:00:00')} -6106060800
datetest 3.9 {strftime('%S','2003-10-31 12:34:56.432')} 56
datetest 3.10 {strftime('%w','2003-10-31 12:34:56.432')} 5
datetest 3.11.1 {strftime('%W','2003-10-31 12:34:56.432')} 43