From c9c5d74751df98b76c44c12f8052ac03a56409af Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Sat, 17 Sep 2005 13:18:05 +0000 Subject: [PATCH] * 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. --- webcit/ChangeLog | 6 ++++++ webcit/fmt_date.c | 23 +++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/webcit/ChangeLog b/webcit/ChangeLog index 228569f9e..65607ec16 100644 --- a/webcit/ChangeLog +++ b/webcit/ChangeLog @@ -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 1998-12-03 Nathan Bryant * webserver.c: warning fix + diff --git a/webcit/fmt_date.c b/webcit/fmt_date.c index da9c1d160..640db83c2 100644 --- a/webcit/fmt_date.c +++ b/webcit/fmt_date.c @@ -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], -- 2.30.2