aboutsummaryrefslogtreecommitdiff
path: root/src/qt
diff options
context:
space:
mode:
Diffstat (limited to 'src/qt')
-rw-r--r--src/qt/guiutil.cpp4
-rw-r--r--src/qt/guiutil.h2
-rw-r--r--src/qt/rpcconsole.cpp10
-rw-r--r--src/qt/rpcconsole.h5
4 files changed, 12 insertions, 9 deletions
diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp
index 4262866f32..35e4ab4ecd 100644
--- a/src/qt/guiutil.cpp
+++ b/src/qt/guiutil.cpp
@@ -20,6 +20,7 @@
#include <script/script.h>
#include <script/standard.h>
#include <util/system.h>
+#include <util/time.h>
#ifdef WIN32
#ifndef NOMINMAX
@@ -705,8 +706,9 @@ QString ConnectionTypeToQString(ConnectionType conn_type, bool prepend_direction
assert(false);
}
-QString formatDurationStr(int secs)
+QString formatDurationStr(std::chrono::seconds dur)
{
+ const auto secs = count_seconds(dur);
QStringList strList;
int days = secs / 86400;
int hours = (secs % 86400) / 3600;
diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h
index 211f3f506d..eba8eb0bd8 100644
--- a/src/qt/guiutil.h
+++ b/src/qt/guiutil.h
@@ -221,7 +221,7 @@ namespace GUIUtil
QString ConnectionTypeToQString(ConnectionType conn_type, bool prepend_direction);
/** Convert seconds into a QString with days, hours, mins, secs */
- QString formatDurationStr(int secs);
+ QString formatDurationStr(std::chrono::seconds dur);
/** Format CNodeStats.nServices bitmask into a user-readable string */
QString formatServicesStr(quint64 mask);
diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp
index 5b95c92392..3267d20bee 100644
--- a/src/qt/rpcconsole.cpp
+++ b/src/qt/rpcconsole.cpp
@@ -1137,7 +1137,7 @@ void RPCConsole::on_sldGraphRange_valueChanged(int value)
void RPCConsole::setTrafficGraphRange(int mins)
{
ui->trafficGraph->setGraphRangeMins(mins);
- ui->lblGraphRange->setText(GUIUtil::formatDurationStr(mins * 60));
+ ui->lblGraphRange->setText(GUIUtil::formatDurationStr(std::chrono::minutes{mins}));
}
void RPCConsole::updateTrafficStats(quint64 totalBytesIn, quint64 totalBytesOut)
@@ -1168,10 +1168,10 @@ void RPCConsole::updateDetailWidget()
if (stats->nodeStats.m_bip152_highbandwidth_from) bip152_hb_settings += (bip152_hb_settings.isEmpty() ? ts.from : QLatin1Char('/') + ts.from);
if (bip152_hb_settings.isEmpty()) bip152_hb_settings = ts.no;
ui->peerHighBandwidth->setText(bip152_hb_settings);
- const int64_t time_now{GetTimeSeconds()};
- ui->peerConnTime->setText(GUIUtil::formatDurationStr(time_now - stats->nodeStats.nTimeConnected));
- ui->peerLastBlock->setText(TimeDurationField(time_now, stats->nodeStats.nLastBlockTime));
- ui->peerLastTx->setText(TimeDurationField(time_now, stats->nodeStats.nLastTXTime));
+ const auto time_now{GetTime<std::chrono::seconds>()};
+ ui->peerConnTime->setText(GUIUtil::formatDurationStr(time_now - std::chrono::seconds{stats->nodeStats.nTimeConnected}));
+ ui->peerLastBlock->setText(TimeDurationField(time_now, std::chrono::seconds{stats->nodeStats.nLastBlockTime}));
+ ui->peerLastTx->setText(TimeDurationField(time_now, std::chrono::seconds{stats->nodeStats.nLastTXTime}));
ui->peerLastSend->setText(TimeDurationField(time_now, stats->nodeStats.m_last_send));
ui->peerLastRecv->setText(TimeDurationField(time_now, stats->nodeStats.m_last_recv));
ui->peerBytesSent->setText(GUIUtil::formatBytes(stats->nodeStats.nSendBytes));
diff --git a/src/qt/rpcconsole.h b/src/qt/rpcconsole.h
index 2412ae543c..fc6e85b41a 100644
--- a/src/qt/rpcconsole.h
+++ b/src/qt/rpcconsole.h
@@ -175,8 +175,9 @@ private:
void updateNetworkState();
/** Helper for the output of a time duration field. Inputs are UNIX epoch times. */
- QString TimeDurationField(uint64_t time_now, uint64_t time_at_event) const {
- return time_at_event ? GUIUtil::formatDurationStr(time_now - time_at_event) : tr("Never");
+ QString TimeDurationField(std::chrono::seconds time_now, std::chrono::seconds time_at_event) const
+ {
+ return time_at_event.count() ? GUIUtil::formatDurationStr(time_now - time_at_event) : tr("Never");
}
private Q_SLOTS: