| 524 | } |
| 525 | |
| 526 | QString FormatDialogsDate(const QDateTime &lastTime, bool showSeconds) { |
| 527 | // Show all dates that are in the last 20 hours in time format. |
| 528 | constexpr int kRecentlyInSeconds = 20 * 3600; |
| 529 | |
| 530 | const auto now = QDateTime::currentDateTime(); |
| 531 | const auto nowDate = now.date(); |
| 532 | const auto lastDate = lastTime.date(); |
| 533 | |
| 534 | if ((lastDate == nowDate) |
| 535 | || (std::abs(lastTime.secsTo(now)) < kRecentlyInSeconds)) { |
| 536 | return QLocale().toString(lastTime.time(), showSeconds ? QLocale::system().timeFormat(QLocale::LongFormat).remove("t") : QLocale::system().timeFormat(QLocale::ShortFormat)); |
| 537 | } else if (std::abs(lastDate.daysTo(nowDate)) < 7) { |
| 538 | return langDayOfWeek(lastDate); |
| 539 | } else { |
| 540 | return QLocale().toString(lastDate, QLocale::ShortFormat); |
| 541 | } |
| 542 | } |
| 543 | |
| 544 | } // namespace Ui |
no test coverage detected