From 56e27ced2555fe6d2ae4644c391cc81a9b5bfd85 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Sun, 1 Sep 2019 22:58:26 +0200 Subject: Format date (close to) the old way in qml timeline --- src/timeline2/TimelineModel.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/timeline2/TimelineModel.cpp') diff --git a/src/timeline2/TimelineModel.cpp b/src/timeline2/TimelineModel.cpp index d7eb02d0..6f212833 100644 --- a/src/timeline2/TimelineModel.cpp +++ b/src/timeline2/TimelineModel.cpp @@ -1,5 +1,7 @@ #include "TimelineModel.h" +#include + #include "Logging.h" #include "Utils.h" @@ -196,3 +198,18 @@ TimelineModel::displayName(QString id) const { return Cache::displayName(room_id_, id); } + +QString +TimelineModel::formatDateSeparator(QDate date) const +{ + auto now = QDateTime::currentDateTime(); + + QString fmt = QLocale::system().dateFormat(QLocale::LongFormat); + + if (now.date().year() == date.year()) { + QRegularExpression rx("[^a-zA-Z]*y+[^a-zA-Z]*"); + fmt = fmt.remove(rx); + } + + return date.toString(fmt); +} -- cgit 1.5.1