* The date/time stamp of messages are now output using JavaScript's
authorArt Cancro <ajc@citadel.org>
Fri, 24 Jun 2005 15:17:49 +0000 (15:17 +0000)
committerArt Cancro <ajc@citadel.org>
Fri, 24 Jun 2005 15:17:49 +0000 (15:17 +0000)
  toLocaleString() function, observing the browser's locale and timezone
  instead of the web server's.

webcit/ChangeLog
webcit/messages.c
webcit/static/wclib.js

index 607d2db7b41536a2be99df87ac762b650c7e2534..224ef1a65d0ecd74be765246e5ef3464eaac92c8 100644 (file)
@@ -1,4 +1,9 @@
 $Log$
+Revision 619.11  2005/06/24 15:17:48  ajc
+* The date/time stamp of messages are now output using JavaScript's
+  toLocaleString() function, observing the browser's locale and timezone
+  instead of the web server's.
+
 Revision 619.10  2005/06/23 04:01:59  ajc
 * groupdav_main.c: remove double slashes in path name
   (suggested by Johannes Schneider)
@@ -2643,3 +2648,4 @@ Sun Dec  6 19:50:55 EST 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
 
 1998-12-03 Nathan Bryant <bryant@cs.usm.maine.edu>
        * webserver.c: warning fix
+
index 908a871a08ce8e20873df8d294abf73114a116c8..6e4890d54971f61ce3f27efc03571b40d76afbe8 100644 (file)
@@ -416,7 +416,6 @@ void read_message(long msgnum) {
        char node[SIZ];
        char rfca[SIZ];
        char reply_to[512];
-       char now[SIZ];
        int format_type = 0;
        int nhdr = 0;
        int bq = 0;
@@ -500,8 +499,9 @@ void read_message(long msgnum) {
                if (!strncasecmp(buf, "rcpt=", 5))
                        wprintf("to %s ", &buf[5]);
                if (!strncasecmp(buf, "time=", 5)) {
-                       fmt_date(now, atol(&buf[5]), 0);
-                       wprintf("%s ", now);
+                       wprintf("<script type=\"text/javascript\">"
+                               "output_datetime(%s);"
+                               "</script> ", &buf[5]);
                }
 
                if (!strncasecmp(buf, "part=", 5)) {
@@ -1663,7 +1663,7 @@ void display_enter(void)
        }
 
        now = time(NULL);
-       fmt_date(buf, now, 0);
+       strcpy(buf, "");
        strcat(&buf[strlen(buf)], " <I>from</I> ");
        stresc(&buf[strlen(buf)], WC->wc_username, 1, 1);
        if (strlen(bstr("recp")) > 0) {
@@ -1686,7 +1686,11 @@ void display_enter(void)
        wprintf("<input type=\"hidden\" name=\"postseq\" value=\"%ld\">\n",
                now);
 
-       wprintf("%s<br>\n", buf);       /* header bar */
+       /* header bar */
+       wprintf("<script type=\"text/javascript\">"
+               "output_datetime(%ld);"
+               "</script> ", now);
+       wprintf("%s<br>\n", buf);
        wprintf("<img src=\"static/enter.gif\" align=middle alt=\" \">");
                /* "onLoad=\"document.enterform.msgtext.focus();\" " */
        wprintf("<font size=-1>Subject (optional):</font>"
index b78b5473ab02c2daf4c20a15a4010404b0f856df..25ca7d6dc8f82a8d9e5b127af42ae60db3e5a135 100644 (file)
@@ -27,3 +27,12 @@ function hide_page_popup() {
                document.poppedLayer = eval('document.layers[\'`page_popup\']');
 document.poppedLayer.style.visibility = "hidden";
 }
+
+
+// Given a unix timestamp, outputs a date/time using the browser's
+// timezone and locale.
+function output_datetime(unixtimestamp) {
+       var now = new Date();
+       now.setTime(unixtimestamp * 1000);
+       document.write(now.toLocaleString());
+}