Skip to content

Commit

Permalink
refactor: replace QDateTime::fromTime_t with QDateTime::fromSecsSince…
Browse files Browse the repository at this point in the history
…Epoch
  • Loading branch information
fanquake committed Jun 7, 2021
1 parent 260b1d7 commit 4f5e9fe
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -596,8 +596,8 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel, interfaces::BlockAndH
connect(_clientModel, &ClientModel::numConnectionsChanged, this, &BitcoinGUI::setNumConnections);
connect(_clientModel, &ClientModel::networkActiveChanged, this, &BitcoinGUI::setNetworkActive);

modalOverlay->setKnownBestHeight(tip_info->header_height, QDateTime::fromTime_t(tip_info->header_time));
setNumBlocks(tip_info->block_height, QDateTime::fromTime_t(tip_info->block_time), tip_info->verification_progress, false, SynchronizationState::INIT_DOWNLOAD);
modalOverlay->setKnownBestHeight(tip_info->header_height, QDateTime::fromSecsSinceEpoch(tip_info->header_time));
setNumBlocks(tip_info->block_height, QDateTime::fromSecsSinceEpoch(tip_info->block_time), tip_info->verification_progress, false, SynchronizationState::INIT_DOWNLOAD);
connect(_clientModel, &ClientModel::numBlocksChanged, this, &BitcoinGUI::setNumBlocks);

// Receive and report messages from client model
Expand Down
4 changes: 2 additions & 2 deletions src/qt/clientmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ bool ClientModel::isReleaseVersion() const

QString ClientModel::formatClientStartupTime() const
{
return QDateTime::fromTime_t(GetStartupTime()).toString();
return QDateTime::fromSecsSinceEpoch(GetStartupTime()).toString();
}

QString ClientModel::dataDir() const
Expand Down Expand Up @@ -294,7 +294,7 @@ static void BlockTipChanged(ClientModel* clientmodel, SynchronizationState sync_

bool invoked = QMetaObject::invokeMethod(clientmodel, "numBlocksChanged", Qt::QueuedConnection,
Q_ARG(int, tip.block_height),
Q_ARG(QDateTime, QDateTime::fromTime_t(tip.block_time)),
Q_ARG(QDateTime, QDateTime::fromSecsSinceEpoch(tip.block_time)),
Q_ARG(double, verificationProgress),
Q_ARG(bool, fHeader),
Q_ARG(SynchronizationState, sync_state));
Expand Down
2 changes: 1 addition & 1 deletion src/qt/guiutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ QString dateTimeStr(const QDateTime &date)

QString dateTimeStr(qint64 nTime)
{
return dateTimeStr(QDateTime::fromTime_t((qint32)nTime));
return dateTimeStr(QDateTime::fromSecsSinceEpoch(nTime));
}

QFont fixedPitchFont(bool use_embedded_font)
Expand Down
2 changes: 1 addition & 1 deletion src/qt/recentrequeststablemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class RecentRequestEntry
unsigned int date_timet;
SER_WRITE(obj, date_timet = obj.date.toTime_t());
READWRITE(obj.nVersion, obj.id, date_timet, obj.recipient);
SER_READ(obj, obj.date = QDateTime::fromTime_t(date_timet));
SER_READ(obj, obj.date = QDateTime::fromSecsSinceEpoch(date_timet));
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/qt/rpcconsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ void RPCConsole::setClientModel(ClientModel *model, int bestblock_height, int64_
setNumConnections(model->getNumConnections());
connect(model, &ClientModel::numConnectionsChanged, this, &RPCConsole::setNumConnections);

setNumBlocks(bestblock_height, QDateTime::fromTime_t(bestblock_date), verification_progress, false);
setNumBlocks(bestblock_height, QDateTime::fromSecsSinceEpoch(bestblock_date), verification_progress, false);
connect(model, &ClientModel::numBlocksChanged, this, &RPCConsole::setNumBlocks);

updateNetworkState();
Expand Down
5 changes: 3 additions & 2 deletions src/qt/transactionfilterproxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
#include <qt/transactionrecord.h>

#include <cstdlib>
#include <limits>

// Earliest date that can be represented (far in the past)
const QDateTime TransactionFilterProxy::MIN_DATE = QDateTime::fromTime_t(0);
const QDateTime TransactionFilterProxy::MIN_DATE = QDateTime::fromSecsSinceEpoch(0);
// Last date that can be represented (far in the future)
const QDateTime TransactionFilterProxy::MAX_DATE = QDateTime::fromTime_t(0xFFFFFFFF);
const QDateTime TransactionFilterProxy::MAX_DATE = QDateTime::fromSecsSinceEpoch(std::numeric_limits<qint64>::max());

TransactionFilterProxy::TransactionFilterProxy(QObject *parent) :
QSortFilterProxyModel(parent),
Expand Down
4 changes: 2 additions & 2 deletions src/qt/transactiontablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const
case TypeRole:
return rec->type;
case DateRole:
return QDateTime::fromTime_t(static_cast<uint>(rec->time));
return QDateTime::fromSecsSinceEpoch(rec->time);
case WatchonlyRole:
return rec->involvesWatchAddress;
case WatchonlyDecorationRole:
Expand All @@ -630,7 +630,7 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const
case TxPlainTextRole:
{
QString details;
QDateTime date = QDateTime::fromTime_t(static_cast<uint>(rec->time));
QDateTime date = QDateTime::fromSecsSinceEpoch(rec->time);
QString txLabel = walletModel->getAddressTableModel()->labelForAddress(QString::fromStdString(rec->address));

details.append(date.toString("M/d/yy HH:mm"));
Expand Down

0 comments on commit 4f5e9fe

Please sign in to comment.