Fossil SCM
Add a -local option to the "date" TH1 command. This allows a custom ticket-edit script to use localtime instead of UTC for the date stamp for when a comment is added. Also modify the default ticket-edit script to show UTC after the date stamp, to avoid ambiguity. Ticket [5c1490e26b8b2f8].
Commit
e07625279cd9ee70b057deb155535373548dd94d
Parent
c429b524654c593…
2 files changed
+9
-2
+1
-1
+9
-2
| --- src/th_main.c | ||
| +++ src/th_main.c | ||
| @@ -168,20 +168,27 @@ | ||
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | /* |
| 171 | 171 | ** TH command: date |
| 172 | 172 | ** |
| 173 | -** Return a string which is the current time and date. | |
| 173 | +** Return a string which is the current time and date. If the | |
| 174 | +** -local option is used, the date appears using localtime instead | |
| 175 | +** of UTC. | |
| 174 | 176 | */ |
| 175 | 177 | static int dateCmd( |
| 176 | 178 | Th_Interp *interp, |
| 177 | 179 | void *p, |
| 178 | 180 | int argc, |
| 179 | 181 | const char **argv, |
| 180 | 182 | int *argl |
| 181 | 183 | ){ |
| 182 | - char *zOut = db_text("??", "SELECT datetime('now')"); | |
| 184 | + char *zOut; | |
| 185 | + if( argc>=2 && argl[1]==6 && memcmp(argv[1],"-local",6)==0 ){ | |
| 186 | + zOut = db_text("??", "SELECT datetime('now','localtime')"); | |
| 187 | + }else{ | |
| 188 | + zOut = db_text("??", "SELECT datetime('now')"); | |
| 189 | + } | |
| 183 | 190 | Th_SetResult(interp, zOut, -1); |
| 184 | 191 | free(zOut); |
| 185 | 192 | return TH_OK; |
| 186 | 193 | } |
| 187 | 194 | |
| 188 | 195 |
| --- src/th_main.c | |
| +++ src/th_main.c | |
| @@ -168,20 +168,27 @@ | |
| 168 | } |
| 169 | |
| 170 | /* |
| 171 | ** TH command: date |
| 172 | ** |
| 173 | ** Return a string which is the current time and date. |
| 174 | */ |
| 175 | static int dateCmd( |
| 176 | Th_Interp *interp, |
| 177 | void *p, |
| 178 | int argc, |
| 179 | const char **argv, |
| 180 | int *argl |
| 181 | ){ |
| 182 | char *zOut = db_text("??", "SELECT datetime('now')"); |
| 183 | Th_SetResult(interp, zOut, -1); |
| 184 | free(zOut); |
| 185 | return TH_OK; |
| 186 | } |
| 187 | |
| 188 |
| --- src/th_main.c | |
| +++ src/th_main.c | |
| @@ -168,20 +168,27 @@ | |
| 168 | } |
| 169 | |
| 170 | /* |
| 171 | ** TH command: date |
| 172 | ** |
| 173 | ** Return a string which is the current time and date. If the |
| 174 | ** -local option is used, the date appears using localtime instead |
| 175 | ** of UTC. |
| 176 | */ |
| 177 | static int dateCmd( |
| 178 | Th_Interp *interp, |
| 179 | void *p, |
| 180 | int argc, |
| 181 | const char **argv, |
| 182 | int *argl |
| 183 | ){ |
| 184 | char *zOut; |
| 185 | if( argc>=2 && argl[1]==6 && memcmp(argv[1],"-local",6)==0 ){ |
| 186 | zOut = db_text("??", "SELECT datetime('now','localtime')"); |
| 187 | }else{ |
| 188 | zOut = db_text("??", "SELECT datetime('now')"); |
| 189 | } |
| 190 | Th_SetResult(interp, zOut, -1); |
| 191 | free(zOut); |
| 192 | return TH_OK; |
| 193 | } |
| 194 | |
| 195 |
+1
-1
| --- src/tktsetup.c | ||
| +++ src/tktsetup.c | ||
| @@ -434,11 +434,11 @@ | ||
| 434 | 434 | @ if {[string length $cmappnd]>0} { |
| 435 | 435 | @ set ctxt "\n\n<hr /><i>[htmlize $login]" |
| 436 | 436 | @ if {$username ne $login} { |
| 437 | 437 | @ set ctxt "$ctxt claiming to be [htmlize $username]" |
| 438 | 438 | @ } |
| 439 | -@ set ctxt "$ctxt added on [date]:</i><br />\n$cmappnd" | |
| 439 | +@ set ctxt "$ctxt added on [date] UTC:</i><br />\n$cmappnd" | |
| 440 | 440 | @ append_field comment $ctxt |
| 441 | 441 | @ } |
| 442 | 442 | @ } |
| 443 | 443 | @ submit_ticket |
| 444 | 444 | @ } |
| 445 | 445 |
| --- src/tktsetup.c | |
| +++ src/tktsetup.c | |
| @@ -434,11 +434,11 @@ | |
| 434 | @ if {[string length $cmappnd]>0} { |
| 435 | @ set ctxt "\n\n<hr /><i>[htmlize $login]" |
| 436 | @ if {$username ne $login} { |
| 437 | @ set ctxt "$ctxt claiming to be [htmlize $username]" |
| 438 | @ } |
| 439 | @ set ctxt "$ctxt added on [date]:</i><br />\n$cmappnd" |
| 440 | @ append_field comment $ctxt |
| 441 | @ } |
| 442 | @ } |
| 443 | @ submit_ticket |
| 444 | @ } |
| 445 |
| --- src/tktsetup.c | |
| +++ src/tktsetup.c | |
| @@ -434,11 +434,11 @@ | |
| 434 | @ if {[string length $cmappnd]>0} { |
| 435 | @ set ctxt "\n\n<hr /><i>[htmlize $login]" |
| 436 | @ if {$username ne $login} { |
| 437 | @ set ctxt "$ctxt claiming to be [htmlize $username]" |
| 438 | @ } |
| 439 | @ set ctxt "$ctxt added on [date] UTC:</i><br />\n$cmappnd" |
| 440 | @ append_field comment $ctxt |
| 441 | @ } |
| 442 | @ } |
| 443 | @ submit_ticket |
| 444 | @ } |
| 445 |