* fmt_date.c: changes to "brief" mode. It now displays time only if the
authorArt Cancro <ajc@citadel.org>
Sat, 17 Sep 2005 13:18:05 +0000 (13:18 +0000)
committerArt Cancro <ajc@citadel.org>
Sat, 17 Sep 2005 13:18:05 +0000 (13:18 +0000)
  date is today, month/day/time if the date is within the last six months,
  and date only for anything older.

webcit/ChangeLog
webcit/fmt_date.c

index 228569f9ec89aeddf465c274021f4cd3b7d815d9..65607ec1661454126f2af9502a2af7ca4e007f71 100644 (file)
@@ -1,4 +1,9 @@
 $Log$
+Revision 625.7  2005/09/17 13:18:05  ajc
+* fmt_date.c: changes to "brief" mode.  It now displays time only if the
+  date is today, month/day/time if the date is within the last six months,
+  and date only for anything older.
+
 Revision 625.6  2005/09/17 03:00:06  ajc
 * Fixed the autocompletion for CC: and BCC:
 * Moved the autocompletion styles into the stylesheet where they belong
@@ -2976,3 +2981,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 da9c1d160806c6e62fe9364529e0e6771c4972ef..640db83c2f1a698e21e78848ef334674005966bb 100644 (file)
@@ -48,6 +48,7 @@ void fmt_date(char *buf, time_t thetime, int brief)
 
        if (brief) {
 
+               /* If date == today, show only the time */
                if ((tm.tm_year == today_tm.tm_year)
                  &&(tm.tm_mon == today_tm.tm_mon)
                  &&(tm.tm_mday == today_tm.tm_mday)) {
@@ -63,6 +64,28 @@ void fmt_date(char *buf, time_t thetime, int brief)
                                );
                        }
                }
+
+               /* Otherwise, for messages up to 6 months old, show the
+                * month and day, and the time */
+               else if (today_timet - thetime < 15552000) {
+                       if (!strcasecmp(calhourformat, "24")) {
+                               sprintf(buf, "%s %d %2d:%02d",
+                                       ascmonths[tm.tm_mon],
+                                       tm.tm_mday,
+                                       tm.tm_hour, tm.tm_min
+                               );
+                       }
+                       else {
+                               sprintf(buf, "%s %d %2d:%02d%s",
+                                       ascmonths[tm.tm_mon],
+                                       tm.tm_mday,
+                                       hour, tm.tm_min,
+                                       ((tm.tm_hour >= 12) ? "pm" : "am")
+                               );
+                       }
+               }
+
+               /* older than 6 months, show only the date */
                else {
                        sprintf(buf, "%s %d %d",
                                ascmonths[tm.tm_mon],