UI: StatisticsPage: Tweak date formats.

This commit is contained in:
Nodir Temirkhodjaev 2017-12-12 15:43:49 +05:00
parent 0ba14268ff
commit c0838882d7
3 changed files with 9 additions and 7 deletions

View File

@ -97,7 +97,7 @@ BasePage {
id: ipListView id: ipListView
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
spacing: 4 spacing: 5
model: ipListModel model: ipListModel

View File

@ -192,7 +192,7 @@ BasePage {
id: trafListView id: trafListView
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
spacing: 4 spacing: 5
clip: true clip: true
model: trafListModel model: trafListModel

View File

@ -1,6 +1,7 @@
#include "dateutil.h" #include "dateutil.h"
#include <QDateTime> #include <QDateTime>
#include <QLocale>
DateUtil::DateUtil(QObject *parent) : DateUtil::DateUtil(QObject *parent) :
QObject(parent) QObject(parent)
@ -48,25 +49,26 @@ qint32 DateUtil::addUnixMonths(qint32 unixHour, int months)
QString DateUtil::formatTime(qint64 unixTime) QString DateUtil::formatTime(qint64 unixTime)
{ {
return formatDateTime(unixTime, "yyyy-MM-dd hh:mm:ss"); return formatDateTime(unixTime, "dd-MMM-yyyy hh:mm:ss");
} }
QString DateUtil::formatHour(qint64 unixTime) QString DateUtil::formatHour(qint64 unixTime)
{ {
return formatDateTime(unixTime, "yyyy-MM-dd hh:00"); return formatDateTime(unixTime, "dd-MMM-yyyy hh:00");
} }
QString DateUtil::formatDay(qint64 unixTime) QString DateUtil::formatDay(qint64 unixTime)
{ {
return formatDateTime(unixTime, "yyyy-MM-dd"); return formatDateTime(unixTime, "dd MMMM yyyy");
} }
QString DateUtil::formatMonth(qint64 unixTime) QString DateUtil::formatMonth(qint64 unixTime)
{ {
return formatDateTime(unixTime, "yyyy-MM"); return formatDateTime(unixTime, "MMMM yyyy");
} }
QString DateUtil::formatDateTime(qint64 unixTime, const QString &format) QString DateUtil::formatDateTime(qint64 unixTime, const QString &format)
{ {
return QDateTime::fromSecsSinceEpoch(unixTime).toString(format); const QDateTime dt = QDateTime::fromSecsSinceEpoch(unixTime);
return QLocale().toString(dt, format);
} }