]> code.citadel.org Git - citadel.git/blobdiff - webcit/http_datestring.c
* templatize user editing
[citadel.git] / webcit / http_datestring.c
index aa0aa6ebfb306d9ba304546e564cbce8cead66bb..d4c69bf6c250506d534db938977b737c028cd839 100644 (file)
@@ -1,25 +1,32 @@
 /*
  * $Id$
- *
- * Function to generate HTTP-compliant textual time/date stamp
+ */
+/**
+ * \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 - 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 - do not translate - these are not for human consumption */
 static char *httpdate_weekdays[] = {
        "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
 };
 
 
-/*
- * Supplied with a unix timestamp, generate a textual time/date stamp
+/**
+ * \brief Supplied with a unix timestamp, generate a textual time/date stamp
+ * \param buf the return buffer
+ * \param n the size of the buffer
+ * \param xtime the time to format as string
  */
 void http_datestring(char *buf, size_t n, time_t xtime) {
        struct tm t;
@@ -29,7 +36,7 @@ void http_datestring(char *buf, size_t n, time_t xtime) {
 
        localtime_r(&xtime, &t);
 
-       /* Convert "seconds west of GMT" to "hours/minutes offset" */
+       /** Convert "seconds west of GMT" to "hours/minutes offset" */
 #ifdef HAVE_STRUCT_TM_TM_GMTOFF
        offset = t.tm_gmtoff;
 #else
@@ -56,3 +63,26 @@ 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);
+}
+
+/*@}*/