Fossil SCM
Use the new timediff() function of SQLite 3.43.0 to refactor the "Duration of Project" line on the /stat page to be "Project Age".
Commit
2abb23dba8bdc5dba8bbc3cd99a12af622db7286c3cf6c6a1b85056b50e08aaf
Parent
1e64c2c10bd031a…
2 files changed
+3
-3
+12
-4
+3
-3
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -712,14 +712,14 @@ | ||
| 712 | 712 | fossil_limit_memory(1); |
| 713 | 713 | |
| 714 | 714 | /* When updating the minimum SQLite version, change the number here, |
| 715 | 715 | ** and also MINIMUM_SQLITE_VERSION value set in ../auto.def. Take |
| 716 | 716 | ** care that both places agree! */ |
| 717 | - if( sqlite3_libversion_number()<3038000 | |
| 718 | - || strncmp(sqlite3_sourceid(),"2022-01-12",10)<0 | |
| 717 | + if( sqlite3_libversion_number()<3043000 | |
| 718 | + || strncmp(sqlite3_sourceid(),"2023-06-12",10)<0 | |
| 719 | 719 | ){ |
| 720 | - fossil_panic("Unsuitable SQLite version %s, must be at least 3.38.0", | |
| 720 | + fossil_panic("Unsuitable SQLite version %s, must be at least 3.43.0", | |
| 721 | 721 | sqlite3_libversion()); |
| 722 | 722 | } |
| 723 | 723 | |
| 724 | 724 | sqlite3_config(SQLITE_CONFIG_MULTITHREAD); |
| 725 | 725 | sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0); |
| 726 | 726 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -712,14 +712,14 @@ | |
| 712 | fossil_limit_memory(1); |
| 713 | |
| 714 | /* When updating the minimum SQLite version, change the number here, |
| 715 | ** and also MINIMUM_SQLITE_VERSION value set in ../auto.def. Take |
| 716 | ** care that both places agree! */ |
| 717 | if( sqlite3_libversion_number()<3038000 |
| 718 | || strncmp(sqlite3_sourceid(),"2022-01-12",10)<0 |
| 719 | ){ |
| 720 | fossil_panic("Unsuitable SQLite version %s, must be at least 3.38.0", |
| 721 | sqlite3_libversion()); |
| 722 | } |
| 723 | |
| 724 | sqlite3_config(SQLITE_CONFIG_MULTITHREAD); |
| 725 | sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0); |
| 726 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -712,14 +712,14 @@ | |
| 712 | fossil_limit_memory(1); |
| 713 | |
| 714 | /* When updating the minimum SQLite version, change the number here, |
| 715 | ** and also MINIMUM_SQLITE_VERSION value set in ../auto.def. Take |
| 716 | ** care that both places agree! */ |
| 717 | if( sqlite3_libversion_number()<3043000 |
| 718 | || strncmp(sqlite3_sourceid(),"2023-06-12",10)<0 |
| 719 | ){ |
| 720 | fossil_panic("Unsuitable SQLite version %s, must be at least 3.43.0", |
| 721 | sqlite3_libversion()); |
| 722 | } |
| 723 | |
| 724 | sqlite3_config(SQLITE_CONFIG_MULTITHREAD); |
| 725 | sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0); |
| 726 |
+12
-4
| --- src/stat.c | ||
| +++ src/stat.c | ||
| @@ -141,10 +141,12 @@ | ||
| 141 | 141 | i64 t, fsize; |
| 142 | 142 | int n, m; |
| 143 | 143 | int szMax, szAvg; |
| 144 | 144 | int brief; |
| 145 | 145 | const char *p; |
| 146 | + char *z; | |
| 147 | + int Y, M, D; | |
| 146 | 148 | |
| 147 | 149 | login_check_credentials(); |
| 148 | 150 | if( !g.perm.Read ){ login_needed(g.anon.Read); return; } |
| 149 | 151 | brief = P("brief")!=0; |
| 150 | 152 | style_header("Repository Statistics"); |
| @@ -257,14 +259,20 @@ | ||
| 257 | 259 | @ <tr><th>Number Of Forum Posts:</th> |
| 258 | 260 | @ <td>%,d(n) on %d(nThread) threads</td></tr> |
| 259 | 261 | } |
| 260 | 262 | } |
| 261 | 263 | } |
| 262 | - @ <tr><th>Duration Of Project:</th><td> | |
| 263 | - n = db_int(0, "SELECT julianday('now') - (SELECT min(mtime) FROM event)" | |
| 264 | - " + 0.99"); | |
| 265 | - @ %,d(n) days or approximately %.2f(n/365.2425) years. | |
| 264 | + @ <tr><th>Project Age:</th><td> | |
| 265 | + z = db_text(0, "SELECT timediff('now',(SELECT min(mtime) FROM event));"); | |
| 266 | + sscanf(z, "+%d-%d-%d", &Y, &M, &D); | |
| 267 | + if( Y>0 ){ | |
| 268 | + @ %d(Y) years, \ | |
| 269 | + } | |
| 270 | + if( M>0 ){ | |
| 271 | + @ %d(M) months, \ | |
| 272 | + } | |
| 273 | + @ %d(D) days | |
| 266 | 274 | @ </td></tr> |
| 267 | 275 | p = db_get("project-code", 0); |
| 268 | 276 | if( p ){ |
| 269 | 277 | @ <tr><th>Project ID:</th> |
| 270 | 278 | @ <td>%h(p) %h(db_get("project-name",""))</td></tr> |
| 271 | 279 |
| --- src/stat.c | |
| +++ src/stat.c | |
| @@ -141,10 +141,12 @@ | |
| 141 | i64 t, fsize; |
| 142 | int n, m; |
| 143 | int szMax, szAvg; |
| 144 | int brief; |
| 145 | const char *p; |
| 146 | |
| 147 | login_check_credentials(); |
| 148 | if( !g.perm.Read ){ login_needed(g.anon.Read); return; } |
| 149 | brief = P("brief")!=0; |
| 150 | style_header("Repository Statistics"); |
| @@ -257,14 +259,20 @@ | |
| 257 | @ <tr><th>Number Of Forum Posts:</th> |
| 258 | @ <td>%,d(n) on %d(nThread) threads</td></tr> |
| 259 | } |
| 260 | } |
| 261 | } |
| 262 | @ <tr><th>Duration Of Project:</th><td> |
| 263 | n = db_int(0, "SELECT julianday('now') - (SELECT min(mtime) FROM event)" |
| 264 | " + 0.99"); |
| 265 | @ %,d(n) days or approximately %.2f(n/365.2425) years. |
| 266 | @ </td></tr> |
| 267 | p = db_get("project-code", 0); |
| 268 | if( p ){ |
| 269 | @ <tr><th>Project ID:</th> |
| 270 | @ <td>%h(p) %h(db_get("project-name",""))</td></tr> |
| 271 |
| --- src/stat.c | |
| +++ src/stat.c | |
| @@ -141,10 +141,12 @@ | |
| 141 | i64 t, fsize; |
| 142 | int n, m; |
| 143 | int szMax, szAvg; |
| 144 | int brief; |
| 145 | const char *p; |
| 146 | char *z; |
| 147 | int Y, M, D; |
| 148 | |
| 149 | login_check_credentials(); |
| 150 | if( !g.perm.Read ){ login_needed(g.anon.Read); return; } |
| 151 | brief = P("brief")!=0; |
| 152 | style_header("Repository Statistics"); |
| @@ -257,14 +259,20 @@ | |
| 259 | @ <tr><th>Number Of Forum Posts:</th> |
| 260 | @ <td>%,d(n) on %d(nThread) threads</td></tr> |
| 261 | } |
| 262 | } |
| 263 | } |
| 264 | @ <tr><th>Project Age:</th><td> |
| 265 | z = db_text(0, "SELECT timediff('now',(SELECT min(mtime) FROM event));"); |
| 266 | sscanf(z, "+%d-%d-%d", &Y, &M, &D); |
| 267 | if( Y>0 ){ |
| 268 | @ %d(Y) years, \ |
| 269 | } |
| 270 | if( M>0 ){ |
| 271 | @ %d(M) months, \ |
| 272 | } |
| 273 | @ %d(D) days |
| 274 | @ </td></tr> |
| 275 | p = db_get("project-code", 0); |
| 276 | if( p ){ |
| 277 | @ <tr><th>Project ID:</th> |
| 278 | @ <td>%h(p) %h(db_get("project-name",""))</td></tr> |
| 279 |