diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2013-10-10 19:42:11 +0200 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2013-10-10 19:42:11 +0200 |
commit | 2bde9453ed81a1536dce6bc686893dd3abf9b461 (patch) | |
tree | 8484413725307e8dcab59a9b9b42e1716fe06918 /src/gui/curses/gui-curses-chat.c | |
parent | 2a50f23e3d8b753dd341ff3a62c715de3c6d9705 (diff) | |
download | weechat-2bde9453ed81a1536dce6bc686893dd3abf9b461.zip |
core: use one date format when day changes from day to day+1
Diffstat (limited to 'src/gui/curses/gui-curses-chat.c')
-rw-r--r-- | src/gui/curses/gui-curses-chat.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/gui/curses/gui-curses-chat.c b/src/gui/curses/gui-curses-chat.c index 434395a90..8bdbd52e4 100644 --- a/src/gui/curses/gui-curses-chat.c +++ b/src/gui/curses/gui-curses-chat.c @@ -600,11 +600,35 @@ gui_chat_display_day_changed (struct t_gui_window *window, int simulate) { char temp_message[1024], message[1024], *message_with_color; + int year1, year1_last_yday; if (simulate || (!simulate && (window->win_chat_cursor_y >= window->win_chat_height))) return; + /* + * if date1 is given, compare date1 and date2; if date2 is date1 + 1 day, + * do not display date1 (so wee keep date1 if date2 is > date1 + 1 day) + */ + if (date1) + { + if (date1->tm_year == date2->tm_year) + { + if (date1->tm_yday == date2->tm_yday - 1) + date1 = NULL; + } + else if ((date1->tm_year == date2->tm_year - 1) && (date2->tm_yday == 0)) + { + /* date2 is 01/01, then check if date1 is 31/12 */ + year1 = date1->tm_year + 1900; + year1_last_yday = (((year1 % 400) == 0) + || (((year1 % 4) == 0) && ((year1 % 100) != 0))) ? + 365 : 364; + if (date1->tm_yday == year1_last_yday) + date1 = NULL; + } + } + /* build the message to display */ if (date1) { |