diff --git a/application/views/ConversationView.cpp b/application/views/ConversationView.cpp index 8721116..c3deda7 100644 --- a/application/views/ConversationView.cpp +++ b/application/views/ConversationView.cpp @@ -352,7 +352,7 @@ ConversationView::_AppendMessage(BMessage* msg) } if (sender_name.IsEmpty() == true) { - fReceiveView->AppendGenericMessage(body.String()); + fReceiveView->AppendGeneric(body.String()); continue; } diff --git a/application/views/RenderView.cpp b/application/views/RenderView.cpp index 1d93914..d6130f6 100644 --- a/application/views/RenderView.cpp +++ b/application/views/RenderView.cpp @@ -10,7 +10,9 @@ RenderView::RenderView(const char* name) : - RunView(name) + RunView(name), + fLastDay(364), + fLastYear(64) { } @@ -32,7 +34,7 @@ RenderView::AppendMessage(const char* nick, const char* message, void -RenderView::AppendGenericMessage(const char* message) +RenderView::AppendGeneric(const char* message) { if (BString(message).IsEmpty() == true) return; AppendTimestamp(time(NULL)); @@ -44,11 +46,26 @@ RenderView::AppendGenericMessage(const char* message) void RenderView::AppendTimestamp(time_t time) { + tm* tm = localtime(&time); + + // If day changed, print date divider + if (fLastDay < tm->tm_yday || fLastYear < tm->tm_year) { + char datestamp[11] = { '\0' }; + strftime(datestamp, 10, "%Y-%m-%d", tm); + BString stamp("――― %date% ―――\n"); + stamp.ReplaceAll("%date%", datestamp); + + Append(stamp.String(), ui_color(B_PANEL_TEXT_COLOR), B_ITALIC_FACE); + + fLastDay = tm->tm_yday; + fLastYear = tm->tm_year; + } + if (time == 0) { Append("[xx:xx] ", ui_color(B_LINK_HOVER_COLOR)); return; } char timestamp[9] = { '\0' }; - strftime(timestamp, 8, "[%H:%M] ", localtime(&time)); + strftime(timestamp, 8, "[%H:%M] ", tm); Append(timestamp, ui_color(B_LINK_HOVER_COLOR)); } diff --git a/application/views/RenderView.h b/application/views/RenderView.h index b880e2b..237b5ad 100644 --- a/application/views/RenderView.h +++ b/application/views/RenderView.h @@ -14,8 +14,12 @@ public: void AppendMessage(const char* nick, const char* message, rgb_color nameColor, time_t time = 0); - void AppendGenericMessage(const char* message); + void AppendGeneric(const char* message); void AppendTimestamp(time_t time = 0); + +private: + int fLastDay; + int fLastYear; }; #endif // _RENDER_VIEW_H