diff options
Diffstat (limited to 'board.cpp')
-rw-r--r-- | board.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -212,17 +212,20 @@ QString Board::renderHumanDate(const QDateTime &dateTime) QString Board::renderHumanTime(const QDateTime &dateTime) { + const QDateTime now = QDateTime::currentDateTime(); QDateTime localDateTime = dateTime.toLocalTime(); - const int secs = localDateTime.secsTo(QDateTime::currentDateTime()); + const int secs = localDateTime.secsTo(now); if (secs < 1) { return tr("Just now"); } else if (secs < 60) { return tr("%n second(s) ago", 0, secs); } else if (secs < 3600) { - int mins = (secs + 10) / 3600; // + 10 to round a bit + int mins = (secs + 10) / 60; // + 10 to round a bit return tr("%n minute(s) ago", 0, mins); - } else { + } else if (localDateTime.daysTo(now) < 1) { return localDateTime.time().toString(Qt::DefaultLocaleShortDate); + } else { + return localDateTime.toString(Qt::DefaultLocaleShortDate); } } |