Simplifications to the new timediff() logic.
FossilOrigin-Name: d6954259bd3f8475f3804fd02a1591d037efa9df54da45776863c024ff90e596
This commit is contained in:
parent
cc4bfd9623
commit
7d65f1bec0
12
manifest
12
manifest
@ -1,5 +1,5 @@
|
||||
C New\stest\scases\sfor\sthe\stimediff\senhancements.
|
||||
D 2023-05-30T11:51:45.702
|
||||
C Simplifications\sto\sthe\snew\stimediff()\slogic.
|
||||
D 2023-05-30T14:46:30.043
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||
@ -583,7 +583,7 @@ F src/build.c 5512d5a335334b48d116f1ecd051edef96a60add18ae48e0ea302a395f00f3d9
|
||||
F src/callback.c db3a45e376deff6a16c0058163fe0ae2b73a2945f3f408ca32cf74960b28d490
|
||||
F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e
|
||||
F src/ctime.c 20507cc0b0a6c19cd882fcd0eaeda32ae6a4229fb4b024cfdf3183043d9b703d
|
||||
F src/date.c fc60c1a37df9773d0b764a21947ecbf8a28f09b06069f8a4e44ed6c83706c068
|
||||
F src/date.c cb71f73d5df5303ec6630971b9c8b8c7df466fa3233dbdc643d613806e53e554
|
||||
F src/dbpage.c f3eea5f7ec47e09ee7da40f42b25092ecbe961fc59566b8e5f705f34335b2387
|
||||
F src/dbstat.c ec92074baa61d883de58c945162d9e666c13cd7cf3a23bc38b4d1c4d0b2c2bef
|
||||
F src/delete.c 05e27e3a55dcfeadf2f7ca95a5c5e0928f182c04640ec1954ffa42f3d5c19341
|
||||
@ -2072,8 +2072,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||
P fa9237a8ab803ca3f67fe753516b7bdb98be3d625e8e241ddf9b02509210e225
|
||||
R 51c5fa7aa16d0c81c327481e1cc4975e
|
||||
P f14633ce6ddf28a14b03e2da623d96e439966aa3fc30c26cb0be59c0e15b3e9c
|
||||
R 200e909133393bbb7ad7eb71a74582fc
|
||||
U drh
|
||||
Z dfeb1c0c465184df485198331681092e
|
||||
Z a8e1aeb111a402709c4efa768d7bf30a
|
||||
# Remove this line to create a well-formed Fossil manifest.
|
||||
|
@ -1 +1 @@
|
||||
f14633ce6ddf28a14b03e2da623d96e439966aa3fc30c26cb0be59c0e15b3e9c
|
||||
d6954259bd3f8475f3804fd02a1591d037efa9df54da45776863c024ff90e596
|
26
src/date.c
26
src/date.c
@ -887,7 +887,7 @@ static int parseModifier(
|
||||
** the range 0-11 and DD is limited to 0-30.
|
||||
*/
|
||||
if( z[0]!='+' && z[0]!='-' ) break; /* Must start with +/- */
|
||||
if( n!=5 ) break; /* Must be 4-digit YYYY */
|
||||
if( NEVER(n!=5) ) break; /* Must be 4-digit YYYY */
|
||||
if( getDigits(&z[1], "40f-20a-20d", &Y, &M, &D)!=3 ) break;
|
||||
if( M>=12 ) break; /* M range 0..11 */
|
||||
if( D>=31 ) break; /* D range 0..30 */
|
||||
@ -1400,18 +1400,12 @@ static void timediffFunc(
|
||||
int argc,
|
||||
sqlite3_value **argv
|
||||
){
|
||||
DateTime d1, d2;
|
||||
sqlite3_str *pOut = 0;
|
||||
char sign;
|
||||
int rc;
|
||||
int Y, M;
|
||||
DateTime d1, d2;
|
||||
sqlite3_str sRes;
|
||||
if( isDate(context, 1, argv, &d1) ) return;
|
||||
if( isDate(context, 1, &argv[1], &d2) ) return;
|
||||
pOut = sqlite3_str_new(sqlite3_context_db_handle(context));
|
||||
if( pOut==0 ){
|
||||
sqlite3_result_error_nomem(context);
|
||||
return;
|
||||
}
|
||||
computeYMD_HMS(&d1);
|
||||
computeYMD_HMS(&d2);
|
||||
if( d1.iJD>=d2.iJD ){
|
||||
@ -1439,7 +1433,7 @@ static void timediffFunc(
|
||||
Y--;
|
||||
}
|
||||
d2.M--;
|
||||
if( d2.M<0 ){
|
||||
if( d2.M<1 ){
|
||||
d2.M = 12;
|
||||
d2.Y--;
|
||||
}
|
||||
@ -1487,16 +1481,10 @@ static void timediffFunc(
|
||||
d1.validHMS = 0;
|
||||
d1.validTZ = 0;
|
||||
computeYMD_HMS(&d1);
|
||||
sqlite3_str_appendf(pOut, "%c%04d-%02d-%02d %02d:%02d:%06.3f",
|
||||
sqlite3StrAccumInit(&sRes, 0, 0, 0, 100);
|
||||
sqlite3_str_appendf(&sRes, "%c%04d-%02d-%02d %02d:%02d:%06.3f",
|
||||
sign, Y, M, d1.D-1, d1.h, d1.m, d1.s);
|
||||
rc = sqlite3_str_errcode(pOut);
|
||||
if( rc ){
|
||||
sqlite3_free(sqlite3_str_finish(pOut));
|
||||
sqlite3_result_error_code(context, rc);
|
||||
}else{
|
||||
sqlite3_result_text(context,
|
||||
sqlite3_str_finish(pOut), -1, sqlite3_free);
|
||||
}
|
||||
sqlite3ResultStrAccum(context, &sRes);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user