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].

drh 2010-12-30 14:41 trunk
Commit e07625279cd9ee70b057deb155535373548dd94d
2 files changed +9 -2 +1 -1
+9 -2
--- src/th_main.c
+++ src/th_main.c
@@ -168,20 +168,27 @@
168168
}
169169
170170
/*
171171
** TH command: date
172172
**
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.
174176
*/
175177
static int dateCmd(
176178
Th_Interp *interp,
177179
void *p,
178180
int argc,
179181
const char **argv,
180182
int *argl
181183
){
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
+ }
183190
Th_SetResult(interp, zOut, -1);
184191
free(zOut);
185192
return TH_OK;
186193
}
187194
188195
--- 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 @@
434434
@ if {[string length $cmappnd]>0} {
435435
@ set ctxt "\n\n<hr /><i>[htmlize $login]"
436436
@ if {$username ne $login} {
437437
@ set ctxt "$ctxt claiming to be [htmlize $username]"
438438
@ }
439
-@ set ctxt "$ctxt added on [date]:</i><br />\n$cmappnd"
439
+@ set ctxt "$ctxt added on [date] UTC:</i><br />\n$cmappnd"
440440
@ append_field comment $ctxt
441441
@ }
442442
@ }
443443
@ submit_ticket
444444
@ }
445445
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button