1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-08 14:02:16 +03:00

The %W date specifier in strftime should be measured from the first Monday

of the year.  Ticket #758. (CVS 1805)

FossilOrigin-Name: 50b016b00470e6303ede1173d0447d8239563263
This commit is contained in:
drh
2004-07-18 22:22:43 +00:00
parent 1af3fdb4dc
commit 1020d49a31
4 changed files with 30 additions and 15 deletions

View File

@@ -1,5 +1,5 @@
C An\simproved\sfix\sfor\sthe\smin()\sproblem\sof\sticket\s#800.\s(CVS\s1804) C The\s%W\sdate\sspecifier\sin\sstrftime\sshould\sbe\smeasured\sfrom\sthe\sfirst\sMonday\nof\sthe\syear.\s\sTicket\s#758.\s(CVS\s1805)
D 2004-07-18T21:33:02 D 2004-07-18T22:22:44
F Makefile.in 77d1219b6563476711a7a962e865979a6f314eb0 F Makefile.in 77d1219b6563476711a7a962e865979a6f314eb0
F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457 F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
@@ -29,7 +29,7 @@ F src/auth.c 60db23b98bb94c8b0178180faaf49dc116674217
F src/btree.c 3ed3c19e43bb243f502ee614f6ad0a52e53362a7 F src/btree.c 3ed3c19e43bb243f502ee614f6ad0a52e53362a7
F src/btree.h 934d0ad30b5b419e9291a11da878be349df2277e F src/btree.h 934d0ad30b5b419e9291a11da878be349df2277e
F src/build.c ecc10d4e5232a49f55304dd9b90739f2771e34ef F src/build.c ecc10d4e5232a49f55304dd9b90739f2771e34ef
F src/date.c b3e8b2bef1e3f2ce24e5b057203036defb18c3f1 F src/date.c d42ea73a0b16d5dff9d97e10dc0c05671471b753
F src/delete.c e81545e546f6bc87d7508a93a09ca70695265af3 F src/delete.c e81545e546f6bc87d7508a93a09ca70695265af3
F src/encode.c a876af473d1d636faa3dca51c7571f2e007eea37 F src/encode.c a876af473d1d636faa3dca51c7571f2e007eea37
F src/expr.c d8ee92a9c11113a013f7853acb55453a8e0b2e92 F src/expr.c d8ee92a9c11113a013f7853acb55453a8e0b2e92
@@ -106,7 +106,7 @@ F test/collate6.test 2a45768914f04c1447a69d1358bbede376552675
F test/conflict.test c5b849b01cfbe0a4f63a90cba6f68e2fe3a75f87 F test/conflict.test c5b849b01cfbe0a4f63a90cba6f68e2fe3a75f87
F test/crash.test 3ea432ce624369c04ba1a23a5288115e40f5daa2 F test/crash.test 3ea432ce624369c04ba1a23a5288115e40f5daa2
F test/crashtest1.c 09c1c7d728ccf4feb9e481671e29dda5669bbcc2 F test/crashtest1.c 09c1c7d728ccf4feb9e481671e29dda5669bbcc2
F test/date.test aed5030482ebc02bd8d386c6c86a29f694ab068d F test/date.test a5cdaed88fe575f2d6f63ff605abb5abc1b7319c
F test/delete.test ec0b455f2dcc0e189d96ee438438ba026c4e51d8 F test/delete.test ec0b455f2dcc0e189d96ee438438ba026c4e51d8
F test/enc.test 2f5463af488d50aef60c6110bec6b21b5efba961 F test/enc.test 2f5463af488d50aef60c6110bec6b21b5efba961
F test/enc2.test 7a60971a62748be6b607b4b4380eb4c5e151a6ec F test/enc2.test 7a60971a62748be6b607b4b4380eb4c5e151a6ec
@@ -233,7 +233,7 @@ F www/tclsqlite.tcl 19191cf2a1010eaeff74c51d83fd5f5a4d899075
F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9 F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9
F www/version3.tcl 092a01f5ef430d2c4acc0ae558d74c4bb89638a0 F www/version3.tcl 092a01f5ef430d2c4acc0ae558d74c4bb89638a0
F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4 F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
P 166234a2b61e1d6a501e48dde1caec0a02bec90b P b6e8b7a13cd9f90e2f7d963d9ddbe591571f3a27
R 2a9b12db8b0f7803d1ccfb6ddc0865f4 R 9aba732fdd9d77e41030d43848e7a6a8
U drh U drh
Z 5efd915ae1cc027bdebade132f88a97d Z df904b51619345b20c4c765ab2f0eb6b

View File

@@ -1 +1 @@
b6e8b7a13cd9f90e2f7d963d9ddbe591571f3a27 50b016b00470e6303ede1173d0447d8239563263

View File

@@ -16,7 +16,7 @@
** sqlite3RegisterDateTimeFunctions() found at the bottom of the file. ** sqlite3RegisterDateTimeFunctions() found at the bottom of the file.
** All other code has file scope. ** All other code has file scope.
** **
** $Id: date.c,v 1.30 2004/06/19 08:18:08 danielk1977 Exp $ ** $Id: date.c,v 1.31 2004/07/18 22:22:44 drh Exp $
** **
** NOTES: ** NOTES:
** **
@@ -822,18 +822,20 @@ static void strftimeFunc(
case 'H': sprintf(&z[j],"%02d",x.h); j+=2; break; case 'H': sprintf(&z[j],"%02d",x.h); j+=2; break;
case 'W': /* Fall thru */ case 'W': /* Fall thru */
case 'j': { case 'j': {
int n; int n; /* Number of days since 1st day of year */
DateTime y = x; DateTime y = x;
y.validJD = 0; y.validJD = 0;
y.M = 1; y.M = 1;
y.D = 1; y.D = 1;
computeJD(&y); computeJD(&y);
n = x.rJD - y.rJD + 1; n = x.rJD - y.rJD;
if( zFmt[i]=='W' ){ if( zFmt[i]=='W' ){
sprintf(&z[j],"%02d",(n+6)/7); int wd; /* 0=Monday, 1=Tuesday, ... 6=Sunday */
wd = ((int)(x.rJD+0.5)) % 7;
sprintf(&z[j],"%02d",(n+7-wd)/7);
j += 2; j += 2;
}else{ }else{
sprintf(&z[j],"%03d",n); sprintf(&z[j],"%03d",n+1);
j += 3; j += 3;
} }
break; break;

View File

@@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The # This file implements regression tests for SQLite library. The
# focus of this file is testing date and time functions. # focus of this file is testing date and time functions.
# #
# $Id: date.test,v 1.7 2004/02/29 01:08:18 drh Exp $ # $Id: date.test,v 1.8 2004/07/18 22:22:44 drh Exp $
set testdir [file dirname $argv0] set testdir [file dirname $argv0]
source $testdir/tester.tcl source $testdir/tester.tcl
@@ -95,7 +95,20 @@ 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 {strftime('%s','2003-10-31 12:34:56.432')} 1067603696
datetest 3.9 {strftime('%S','2003-10-31 12:34:56.432')} 56 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.10 {strftime('%w','2003-10-31 12:34:56.432')} 5
datetest 3.11 {strftime('%W','2003-10-31 12:34:56.432')} 44 datetest 3.11.1 {strftime('%W','2003-10-31 12:34:56.432')} 43
datetest 3.11.2 {strftime('%W','2004-01-01')} 00
datetest 3.11.3 {strftime('%W','2004-01-02')} 00
datetest 3.11.4 {strftime('%W','2004-01-03')} 00
datetest 3.11.5 {strftime('%W','2004-01-04')} 00
datetest 3.11.6 {strftime('%W','2004-01-05')} 01
datetest 3.11.7 {strftime('%W','2004-01-06')} 01
datetest 3.11.8 {strftime('%W','2004-01-07')} 01
datetest 3.11.9 {strftime('%W','2004-01-08')} 01
datetest 3.11.10 {strftime('%W','2004-01-09')} 01
datetest 3.11.11 {strftime('%W','2004-07-18')} 28
datetest 3.11.12 {strftime('%W','2004-12-31')} 52
datetest 3.11.13 {strftime('%W','2007-12-31')} 53
datetest 3.11.14 {strftime('%W','2007-01-01')} 01
datetest 3.12 {strftime('%Y','2003-10-31 12:34:56.432')} 2003 datetest 3.12 {strftime('%Y','2003-10-31 12:34:56.432')} 2003
datetest 3.13 {strftime('%%','2003-10-31 12:34:56.432')} % datetest 3.13 {strftime('%%','2003-10-31 12:34:56.432')} %
datetest 3.14 {strftime('%_','2003-10-31 12:34:56.432')} NULL datetest 3.14 {strftime('%_','2003-10-31 12:34:56.432')} NULL