]> code.citadel.org Git - citadel.git/blobdiff - webcit/http_datestring.c
* templatize user editing
[citadel.git] / webcit / http_datestring.c
index 3a7c806cd2d46bac65ac6008feca5bacda53bad3..d4c69bf6c250506d534db938977b737c028cd839 100644 (file)
@@ -5,6 +5,7 @@
  * \defgroup HTTPDateTime Function to generate HTTP-compliant textual time/date stamp
  * (This module was lifted directly from the Citadel server source)
  *
+ * \ingroup WebcitHttpServer
  */
 /*@{*/
 #include "webcit.h"
@@ -63,4 +64,25 @@ void http_datestring(char *buf, size_t n, time_t xtime) {
 }
 
 
+void tmplput_nowstr(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+{
+       time_t now;
+       now = time(NULL);
+       StrEscAppend(Target, NULL, asctime(localtime(&now)), 0, 0);
+}
+void tmplput_nowno(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+{
+       time_t now;
+       now = time(NULL);
+       StrBufAppendPrintf(Target, "%l", now);
+}
+
+void 
+InitModule_DATE
+(void)
+{
+       RegisterNamespace("DATE:NOW:STR", 1, 2, tmplput_nowstr, CTX_NONE);
+       RegisterNamespace("DATE:NOW:NO", 1, 2, tmplput_nowno, CTX_NONE);
+}
+
 /*@}*/