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 79
79
void ForceActivation ();
80
80
#endif
81
81
82
+ using namespace std ::chrono_literals;
83
+
82
84
namespace GUIUtil {
83
85
84
86
QString dateTimeStr (const QDateTime &date)
@@ -727,6 +729,16 @@ QString formatDurationStr(std::chrono::seconds dur)
727
729
return str_list.join (" " );
728
730
}
729
731
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
+
730
742
QString formatServicesStr (quint64 mask)
731
743
{
732
744
QStringList strList;
Original file line number Diff line number Diff line change @@ -223,6 +223,9 @@ namespace GUIUtil
223
223
/* * Convert seconds into a QString with days, hours, mins, secs */
224
224
QString formatDurationStr (std::chrono::seconds dur);
225
225
226
+ /* * Convert peer connection time to a QString denominated in the most relevant unit. */
227
+ QString FormatPeerAge (std::chrono::seconds time_connected);
228
+
226
229
/* * Format CNodeStats.nServices bitmask into a user-readable string */
227
230
QString formatServicesStr (quint64 mask);
228
231
You can’t perform that action at this time.
0 commit comments