diff options
author | Nicolas Werner <nicolas.werner@hotmail.de> | 2019-07-28 12:50:10 +0200 |
---|---|---|
committer | Nicolas Werner <nicolas.werner@hotmail.de> | 2019-07-28 12:55:08 +0200 |
commit | 1c9cc33902d8242ec25b4416a1662ee6c9902583 (patch) | |
tree | 6d7b32f32b98fdd3efc02dfc3ee43f3db4d41db7 /src/ui | |
parent | Translated using Weblate (German) (diff) | |
download | nheko-1c9cc33902d8242ec25b4416a1662ee6c9902583.tar.xz |
Try to localise timestamps
I'm not sure, if that is the right way, but Qt doesn't really have a way to format custom localised dates, so I tried to find the closest approximations to what we currently have. Relates to #69
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/InfoMessage.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/ui/InfoMessage.cpp b/src/ui/InfoMessage.cpp index fa575d76..27bc0a5f 100644 --- a/src/ui/InfoMessage.cpp +++ b/src/ui/InfoMessage.cpp @@ -2,6 +2,7 @@ #include "Config.h" #include <QDateTime> +#include <QLocale> #include <QPainter> #include <QPen> #include <QtGlobal> @@ -61,14 +62,14 @@ DateSeparator::DateSeparator(QDateTime datetime, QWidget *parent) { auto now = QDateTime::currentDateTime(); - QString fmt; + QString fmt = QLocale::system().dateFormat(QLocale::LongFormat); - if (now.date().year() != datetime.date().year()) - fmt = QString("ddd d MMMM yy"); - else - fmt = QString("ddd d MMMM"); + if (now.date().year() == datetime.date().year()) { + QRegularExpression rx("[^a-zA-Z]*y+[^a-zA-Z]*"); + fmt = fmt.remove(rx); + } - msg_ = datetime.toString(fmt); + msg_ = datetime.date().toString(fmt); QFontMetrics fm{font()}; #if QT_VERSION < QT_VERSION_CHECK(5, 11, 0) |