MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / FormatDialogsDate

Function FormatDialogsDate

Telegram/SourceFiles/ui/text/format_values.cpp:526–542  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

524}
525
526QString 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

Callers 2

ResolveDateTextFunction · 0.85
makePersonalChannelMethod · 0.85

Calls 4

timeMethod · 0.80
langDayOfWeekFunction · 0.50
dateMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected