Attachment "datetolocal.patch" to
ticket [5c1490e2]
added by
anonymous
2010-12-30 13:17:18.
--- th_main_org.c Thu Dec 30 07:32:20 2010
+++ th_main.c Thu Dec 30 13:09:09 2010
@@ -168,6 +168,28 @@
}
/*
+** TH command: datetolocal
+**
+** Convert a string representing date and time from UTC into local time.
+*/
+static int datetolocalCmd(
+ Th_Interp *interp,
+ void *p,
+ int argc,
+ const char **argv,
+ int *argl
+){
+ char *zOut;
+ if( argc!= 2 ){
+ return Th_WrongNumArgs(interp, "datetolocal STRING");
+ }
+ zOut = db_text("??", "SELECT datetime(%Q, 'localtime')", (char*)argv[1]);
+ Th_SetResult(interp, zOut, -1);
+ free(zOut);
+ return TH_OK;
+}
+
+/*
** TH command: date
**
** Return a string which is the current time and date.
@@ -349,6 +371,7 @@
{"hascap", hascapCmd, 0},
{"htmlize", htmlizeCmd, 0},
{"date", dateCmd, 0},
+ {"datetolocal", datetolocalCmd, 0},
{"html", putsCmd, 0},
{"puts", putsCmd, (void*)1},
{"wiki", wikiCmd, 0},