From 0d23c066755a80ffe60632bf6fc83162ebc71984 Mon Sep 17 00:00:00 2001 From: Christopher James Lahey Date: Sat, 23 Dec 2000 06:05:57 +0000 Subject: Changed this to do different formatting of dates based on the current 2000-12-23 Christopher James Lahey * message-list.c (filter_date): Changed this to do different formatting of dates based on the current time. svn path=/trunk/; revision=7140 --- mail/ChangeLog | 5 +++++ mail/message-list.c | 32 +++++++++++++++++++++++++++----- 2 files changed, 32 insertions(+), 5 deletions(-) (limited to 'mail') diff --git a/mail/ChangeLog b/mail/ChangeLog index a94a98b7e8..df5e22876a 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,8 @@ +2000-12-23 Christopher James Lahey + + * message-list.c (filter_date): Changed this to do different + formatting of dates based on the current time. + 2000-12-23 Christopher James Lahey * message-list.c (message_list_get_layout): Added titles to the diff --git a/mail/message-list.c b/mail/message-list.c index 4ce4776258..bc33ae5237 100644 --- a/mail/message-list.c +++ b/mail/message-list.c @@ -921,20 +921,42 @@ static char * filter_date (const void *data) { time_t date = GPOINTER_TO_INT (data); - char buf[26], *p; + time_t nowdate = time(NULL); + time_t yesdate; + struct tm then, now, yesterday; + char buf[26]; if (date == 0) return g_strdup ("?"); + localtime_r (&date, &then); + localtime_r (&nowdate, &now); + if (then.tm_mday == now.tm_mday && + then.tm_mon == now.tm_mon && + then.tm_year == now.tm_year) { + strftime (buf, 26, "Today %T", &then); + } else { + yesdate = nowdate - 60 * 60 * 24; + localtime_r (&yesdate, &yesterday); + if (then.tm_mday == yesterday.tm_mday && + then.tm_mon == yesterday.tm_mon && + then.tm_year == yesterday.tm_year) { + strftime (buf, 26, "Yesterday %T", &then); + } else { + if (then.tm_year == now.tm_year) { + strftime (buf, 26, "%b %d %T", &then); + } else { + strftime (buf, 26, "%b %d %Y", &then); + } + } + } +#if 0 #ifdef CTIME_R_THREE_ARGS ctime_r (&date, buf, 26); #else ctime_r (&date, buf); #endif - - p = strchr (buf, '\n'); - if (p) - *p = '\0'; +#endif return g_strdup (buf); } -- cgit v1.2.3