Call history date formatting adjustments (today, yesterday, etc ...)
This commit is contained in:
parent
536a67652d
commit
a1ff962d1d
2 changed files with 8 additions and 3 deletions
|
|
@ -259,8 +259,13 @@ QString Utils::formatElapsedTime(int seconds, bool dotsSeparator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Utils::formatDate(const QDateTime &date, bool includeTime) {
|
QString Utils::formatDate(const QDateTime &date, bool includeTime) {
|
||||||
|
QString dateDay;
|
||||||
|
if (date.date() == QDate::currentDate()) dateDay = tr("Aujourd'hui");
|
||||||
|
else if (date.date() == QDate::currentDate().addDays(-1)) dateDay = tr("Hier");
|
||||||
|
else {
|
||||||
QString format = date.date().year() == QDateTime::currentDateTime().date().year() ? "dd MMMM" : "dd MMMM yyyy";
|
QString format = date.date().year() == QDateTime::currentDateTime().date().year() ? "dd MMMM" : "dd MMMM yyyy";
|
||||||
auto dateDay = tr(date.date().toString(format).toLocal8Bit().data());
|
auto dateDay = tr(date.date().toString(format).toLocal8Bit().data());
|
||||||
|
}
|
||||||
if (!includeTime) return dateDay;
|
if (!includeTime) return dateDay;
|
||||||
|
|
||||||
auto time = date.time().toString("hh:mm");
|
auto time = date.time().toString("hh:mm");
|
||||||
|
|
|
||||||
|
|
@ -347,7 +347,7 @@ AbstractMainPage {
|
||||||
}
|
}
|
||||||
Text {
|
Text {
|
||||||
// text: modelData.core.date
|
// text: modelData.core.date
|
||||||
text: UtilsCpp.formatDateElapsedTime(modelData.core.date)
|
text: UtilsCpp.formatDate(modelData.core.date, true)
|
||||||
font {
|
font {
|
||||||
pixelSize: 12 * DefaultStyle.dp
|
pixelSize: 12 * DefaultStyle.dp
|
||||||
weight: 300 * DefaultStyle.dp
|
weight: 300 * DefaultStyle.dp
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue