diff options
Diffstat (limited to 'Swift/QtUI/ChatSnippet.cpp')
-rw-r--r-- | Swift/QtUI/ChatSnippet.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Swift/QtUI/ChatSnippet.cpp b/Swift/QtUI/ChatSnippet.cpp index 2218c07..4d23526 100644 --- a/Swift/QtUI/ChatSnippet.cpp +++ b/Swift/QtUI/ChatSnippet.cpp @@ -26,4 +26,23 @@ QString ChatSnippet::escape(const QString& original) { return result; } +QString ChatSnippet::timeToEscapedString(const QDateTime& time) { + QDate now(QDate::currentDate()); + QString date = ""; + if (time.date().daysTo(now) > 0) { + date = "ddd "; + } + if (time.date().month() != now.month()) { + date = date + "MMMM "; + } + if (time.date().daysTo(now) > 6) { + date = date + "d "; + } + if (time.date().year() != now.year()) { + date = date + "yy "; + } + date += "h:mm"; + return escape(time.toString(date)); +} + }; |