From: drh <> Date: Sat, 2 Mar 2024 20:50:56 +0000 (+0000) Subject: Change the magic time-interval names that do truncate-to-same-month to be X-Git-Tag: version-3.46.0~179^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f52afaf738f97ea024d54cfb8fb17fa11fc4fe5e;p=thirdparty%2Fsqlite.git Change the magic time-interval names that do truncate-to-same-month to be "mnth" and "yr" - "month" and "year" without the vowels. FossilOrigin-Name: 296b46c529d79385d7f4db2c789254a992c01ff66fe8ba6d3a3ce4aaac0203fb --- diff --git a/manifest b/manifest index 9ca9c979c5..ad4067ae8c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Proof-of-concept\sfor\snew\stime-interval\soperator\s"pg-month"\sand\s"pg-year"\sthat\nuse\sthe\struncate-to-month\salgorithm\sfor\smonth\soverflow\sinstead\sof\sthe\nwrap-to-next-month\salgorithm\sthat\sis\sused\sby\sSQLite\sby\sdefault. -D 2024-03-02T13:38:46.691 +C Change\sthe\smagic\stime-interval\snames\sthat\sdo\struncate-to-same-month\sto\sbe\n"mnth"\sand\s"yr"\s-\s"month"\sand\s"year"\swithout\sthe\svowels. +D 2024-03-02T20:50:56.172 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -696,7 +696,7 @@ F src/build.c 04f1bcee189f045ab086d84fee95db42cb49df82ff8e84af8136309ff3c8a75f F src/callback.c db3a45e376deff6a16c0058163fe0ae2b73a2945f3f408ca32cf74960b28d490 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c 23331529e654be40ca97d171cbbffe9b3d4c71cc53b78fe5501230675952da8b -F src/date.c f0bde50092368a0eaff79e25ab24c3c91763859adffd91af6bf47cbc13cc7512 +F src/date.c 89083264f1832e2bb892d6b313a6c642a5cd730cfcc89574019aa06c69192dcd F src/dbpage.c 80e46e1df623ec40486da7a5086cb723b0275a6e2a7b01d9f9b5da0f04ba2782 F src/dbstat.c 3b677254d512fcafd4d0b341bf267b38b235ccfddbef24f9154e19360fa22e43 F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500 @@ -1042,7 +1042,7 @@ F test/ctime.test 340f362f41f92972bbd71f44e10569a5cc694062b692231bd08aa6fe6c1c47 F test/cursorhint.test 05cf0febe5c5f8a31f199401fd1c9322249e753950d55f26f9d5aca61408a270 F test/cursorhint2.test 6f3aa9cb19e7418967a10ec6905209bcbb5968054da855fc36c8beee9ae9c42f F test/dataversion1.test 6e5e86ac681f0782e766ebcb56c019ae001522d114e0e111e5ebf68ccf2a7bb8 -F test/date.test b1a5208e6a9c390cf1d1fa4e38a910386b427b0e27046901c6b0fb995d19800e +F test/date.test 9583b421058d8366a06d4a07135ced29b64e31b5e7dafd03a2040bf84ef69adb F test/date2.test 7e12ec14aaf4d5e6294b4ba140445b0eca06ea50062a9c3a69c4ee13d0b6f8b1 F test/date3.test a1b77abf05c6772fe5ca2337cac1398892f2a41e62bce7e6be0f4a08a0e64ae5 F test/date4.test 75dc8401e8c0639a228cd26a6eaa4ff5ea8ccda912b9853d1c9462c476670e17 @@ -2176,11 +2176,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 803481f25020f3c25941f1e7d1a8071937820dea951e8798198b0b0fa3fb48ce -R 736136842d7746223f17212059cfe765 -T *branch * month-truncate -T *sym-month-truncate * -T -sym-trunk * +P b606c0965788f56547435c9318b60e32990877e14a9640d887f33f39d1bdc7c3 +R e86e5c292ead4f22cefd158cafe4f8bc U drh -Z e1892067371eb0569faf26bcf07d7955 +Z 74c79cb89bee4e9b933a0e487d4797f3 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 5a462d35fa..607ef1e19e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b606c0965788f56547435c9318b60e32990877e14a9640d887f33f39d1bdc7c3 \ No newline at end of file +296b46c529d79385d7f4db2c789254a992c01ff66fe8ba6d3a3ce4aaac0203fb \ No newline at end of file diff --git a/src/date.c b/src/date.c index fd225d1e29..d4c3afdd38 100644 --- a/src/date.c +++ b/src/date.c @@ -626,18 +626,18 @@ static int toLocaltime( */ static const struct { u8 nName; /* Length of the name */ - char zName[9]; /* Name of the transformation */ + char zName[7]; /* Name of the transformation */ float rLimit; /* Maximum NNN value for this transform */ float rXform; /* Constant used for this transform */ } aXformType[] = { - { 6, "second", 4.6427e+14, 1.0 }, - { 6, "minute", 7.7379e+12, 60.0 }, - { 4, "hour", 1.2897e+11, 3600.0 }, - { 3, "day", 5373485.0, 86400.0 }, - { 5, "month", 176546.0, 2592000.0 }, - { 4, "year", 14713.0, 31536000.0 }, - { 8, "pg-month", 176546.0, 2592000.0 }, - { 7, "pg-year", 14713.0, 31536000.0 }, + /* 0 */ { 6, "second", 4.6427e+14, 1.0 }, + /* 1 */ { 6, "minute", 7.7379e+12, 60.0 }, + /* 2 */ { 4, "hour", 1.2897e+11, 3600.0 }, + /* 3 */ { 3, "day", 5373485.0, 86400.0 }, + /* 4 */ { 5, "month", 176546.0, 30.0*86400.0 }, + /* 5 */ { 4, "mnth", 176546.0, 30.0*86400.0 }, + /* 6 */ { 4, "year", 14713.0, 365.0*86400.0 }, + /* 7 */ { 2, "yr", 14713.0, 365.0*86400.0 }, }; /* @@ -958,7 +958,7 @@ static int parseModifier( z += n; while( sqlite3Isspace(*z) ) z++; n = sqlite3Strlen30(z); - if( n>10 || n<3 ) break; + if( n>10 || n<2 ) break; if( sqlite3UpperToLower[(u8)z[n-1]]=='s' ) n--; computeJD(p); assert( rc==1 ); @@ -970,26 +970,26 @@ static int parseModifier( ){ int targetMonth = 0; switch( i ){ - case 6: - case 4: { /* Special processing to add months */ - assert( strcmp(aXformType[i].zName,"month")==0 - || strcmp(aXformType[i].zName,"pg-month")==0 ); + case 4: + case 5: { /* Special processing to add months */ + assert( strcmp(aXformType[4].zName,"month")==0 ); + assert( strcmp(aXformType[5].zName,"mnth")==0 ); computeYMD_HMS(p); p->M += (int)r; x = p->M>0 ? (p->M-1)/12 : (p->M-12)/12; p->Y += x; p->M -= x*12; assert( p->M>=1 && p->M<=12 ); - if( i==6 ) targetMonth = p->M; + if( i==5 ) targetMonth = p->M; p->validJD = 0; r -= (int)r; break; } - case 7: - case 5: { /* Special processing to add years */ + case 6: + case 7: { /* Special processing to add years */ int y = (int)r; - assert( strcmp(aXformType[i].zName,"year")==0 - || strcmp(aXformType[i].zName,"pg-year")==0 ); + assert( strcmp(aXformType[6].zName,"year")==0 ); + assert( strcmp(aXformType[7].zName,"yr")==0 ); computeYMD_HMS(p); assert( p->M>=1 && p->M<=12 ); if( i==7 ) targetMonth = p->M; diff --git a/test/date.test b/test/date.test index d536c65fce..f0616f6570 100644 --- a/test/date.test +++ b/test/date.test @@ -148,6 +148,15 @@ datetest 2.51 {datetime('2003-10-22 12:24','nonsense')} NULL datetest 2.60 {datetime('2023-02-31')} {2023-03-03 00:00:00} +datetest 2.70 {date('2024-01-31','+1 month')} {2024-03-02} +datetest 2.71 {date('2024-01-31','+1 mnth')} {2024-02-29} +datetest 2.72 {date('2023-01-31','+1 month')} {2023-03-03} +datetest 2.73 {date('2023-01-31','+1 mnth')} {2023-02-28} +datetest 2.74 {date('2024-02-29','+1 year')} {2025-03-01} +datetest 2.75 {date('2024-02-29','+1 yr')} {2025-02-28} +datetest 2.76 {date('2024-02-29','-110 years')} {1914-03-01} +datetest 2.77 {date('2024-02-29','-110 yrs')} {1914-02-28} + datetest 3.1 {strftime('%d','2003-10-31 12:34:56.432')} 31 datetest 3.2.1 {strftime('pre%fpost','2003-10-31 12:34:56.432')} pre56.432post datetest 3.2.2 {strftime('%f','2003-10-31 12:34:59.9999999')} 59.999