]> code.citadel.org Git - citadel.git/blobdiff - webcit/http_datestring.c
* templatize user editing
[citadel.git] / webcit / http_datestring.c
index 449b52c96d948d9d3be30c940b65dd8c317751a1..d4c69bf6c250506d534db938977b737c028cd839 100644 (file)
@@ -5,17 +5,18 @@
  * \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"
 
-/** HTTP Months */
+/** HTTP Months - do not translate - these are not for human consumption */
 static char *httpdate_months[] = {
        "Jan", "Feb", "Mar", "Apr", "May", "Jun",
        "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
 };
 
-/** HTTP Weekdays */
+/** HTTP Weekdays - do not translate - these are not for human consumption */
 static char *httpdate_weekdays[] = {
        "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
 };
@@ -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);
+}
+
 /*@}*/