diff options
author | Christopher James Lahey <clahey@helixcode.com> | 2000-12-23 14:05:57 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2000-12-23 14:05:57 +0800 |
commit | 0d23c066755a80ffe60632bf6fc83162ebc71984 (patch) | |
tree | a0e8e2f86680420cb44fe14ae54bfad96f1ddb2b /mail/message-list.c | |
parent | bfcb25d071564beddda795e2fd3f0756817c2aab (diff) | |
download | gsoc2013-evolution-0d23c066755a80ffe60632bf6fc83162ebc71984.tar.gz gsoc2013-evolution-0d23c066755a80ffe60632bf6fc83162ebc71984.tar.zst gsoc2013-evolution-0d23c066755a80ffe60632bf6fc83162ebc71984.zip |
Changed this to do different formatting of dates based on the current
2000-12-23 Christopher James Lahey <clahey@helixcode.com>
* message-list.c (filter_date): Changed this to do different
formatting of dates based on the current time.
svn path=/trunk/; revision=7140
Diffstat (limited to 'mail/message-list.c')
-rw-r--r-- | mail/message-list.c | 32 |
1 files changed, 27 insertions, 5 deletions
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); } |