File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change 7979void ForceActivation ();
8080#endif
8181
82+ using namespace std ::chrono_literals;
83+
8284namespace GUIUtil {
8385
8486QString dateTimeStr (const QDateTime &date)
@@ -727,6 +729,16 @@ QString formatDurationStr(std::chrono::seconds dur)
727729 return str_list.join (" " );
728730}
729731
732+ QString FormatPeerAge (std::chrono::seconds time_connected)
733+ {
734+ const auto time_now{GetTime<std::chrono::seconds>()};
735+ const auto age{time_now - time_connected};
736+ if (age >= 24h) return QObject::tr (" %1 d" ).arg (age / 24h);
737+ if (age >= 1h) return QObject::tr (" %1 h" ).arg (age / 1h);
738+ if (age >= 1min) return QObject::tr (" %1 m" ).arg (age / 1min);
739+ return QObject::tr (" %1 s" ).arg (age / 1s);
740+ }
741+
730742QString formatServicesStr (quint64 mask)
731743{
732744 QStringList strList;
Original file line number Diff line number Diff line change @@ -223,6 +223,9 @@ namespace GUIUtil
223223 /* * Convert seconds into a QString with days, hours, mins, secs */
224224 QString formatDurationStr (std::chrono::seconds dur);
225225
226+ /* * Convert peer connection time to a QString denominated in the most relevant unit. */
227+ QString FormatPeerAge (std::chrono::seconds time_connected);
228+
226229 /* * Format CNodeStats.nServices bitmask into a user-readable string */
227230 QString formatServicesStr (quint64 mask);
228231
You can’t perform that action at this time.
0 commit comments