QDateTime::fromTime_t
has been obsoleted in favour of QDateTime::fromSecsSinceEpoch
, which is available from Qt 5.8+.
QDateTime::fromTime_t
has been obsoleted in favour of QDateTime::fromSecsSinceEpoch
, which is available from Qt 5.8+.
Concept ACK.
Interesting that there are no [-Wdeprecated-declarations]
warnings in the build log (Fedora 34 + Qt 5.15.2).
80@@ -81,7 +81,7 @@ QString dateTimeStr(const QDateTime &date)
81
82 QString dateTimeStr(qint64 nTime)
83 {
84- return dateTimeStr(QDateTime::fromTime_t((qint32)nTime));
85+ return dateTimeStr(QDateTime::fromSecsSinceEpoch((qint32)nTime));
0 return dateTimeStr(QDateTime::fromSecsSinceEpoch(nTime));
609@@ -610,7 +610,7 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const
610 case TypeRole:
611 return rec->type;
612 case DateRole:
613- return QDateTime::fromTime_t(static_cast<uint>(rec->time));
614+ return QDateTime::fromSecsSinceEpoch(static_cast<uint>(rec->time));
0 return QDateTime::fromSecsSinceEpoch(qint64{rec->time});
629@@ -630,7 +630,7 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const
630 case TxPlainTextRole:
631 {
632 QString details;
633- QDateTime date = QDateTime::fromTime_t(static_cast<uint>(rec->time));
634+ QDateTime date = QDateTime::fromSecsSinceEpoch(static_cast<uint>(rec->time));
9@@ -10,9 +10,9 @@
10 #include <cstdlib>
11
12 // Earliest date that can be represented (far in the past)
13-const QDateTime TransactionFilterProxy::MIN_DATE = QDateTime::fromTime_t(0);
14+const QDateTime TransactionFilterProxy::MIN_DATE = QDateTime::fromSecsSinceEpoch(0);
15 // Last date that can be represented (far in the future)
16-const QDateTime TransactionFilterProxy::MAX_DATE = QDateTime::fromTime_t(0xFFFFFFFF);
17+const QDateTime TransactionFilterProxy::MAX_DATE = QDateTime::fromSecsSinceEpoch(0xFFFFFFFF);
qint64
could be also fixed.
0const QDateTime TransactionFilterProxy::MAX_DATE = QDateTime::fromSecsSinceEpoch(std::numeric_limits<qint64>::max());
not sure if this compiles
not sure if this compiles
It does.
Also the <limits>
header could be included:
0--- a/src/qt/transactionfilterproxy.cpp
1+++ b/src/qt/transactionfilterproxy.cpp
2@@ -8,11 +8,12 @@
3 #include <qt/transactionrecord.h>
4
5 #include <cstdlib>
6+#include <limits>
7
8 // Earliest date that can be represented (far in the past)
9 const QDateTime TransactionFilterProxy::MIN_DATE = QDateTime::fromSecsSinceEpoch(0);
10 // Last date that can be represented (far in the future)
11-const QDateTime TransactionFilterProxy::MAX_DATE = QDateTime::fromSecsSinceEpoch(0xFFFFFFFF);
12+const QDateTime TransactionFilterProxy::MAX_DATE = QDateTime::fromSecsSinceEpoch(std::numeric_limits<qint64>::max());
13
14 TransactionFilterProxy::TransactionFilterProxy(QObject *parent) :
15 QSortFilterProxyModel(parent),
609@@ -610,7 +610,7 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const
610 case TypeRole:
611 return rec->type;
612 case DateRole:
613- return QDateTime::fromTime_t(static_cast<uint>(rec->time));
614+ return QDateTime::fromSecsSinceEpoch(qint64{rec->time});
rec->time
is of type qint64
:
https://github.com/bitcoin-core/gui/blob/e033ca13794699cf4744e71647db75c583a9a600/src/qt/transactionrecord.h#L116
629@@ -630,7 +630,7 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const
630 case TxPlainTextRole:
631 {
632 QString details;
633- QDateTime date = QDateTime::fromTime_t(static_cast<uint>(rec->time));
634+ QDateTime date = QDateTime::fromSecsSinceEpoch(qint64{rec->time});
rec->time
is of type qint64
:
https://github.com/bitcoin-core/gui/blob/e033ca13794699cf4744e71647db75c583a9a600/src/qt/transactionrecord.h#L116
QDateTime::toTime_t
with QDateTime::toSecsSinceEpoch
.
~ACK bd533e785903af0ba04cb0511c907b98008b056c,~ (will look into CI failures)
0$ git grep fromTime_t | wc -l
10
2$ git grep toTime_t | wc -l
30
Maybe update the OP to mention the second commit changes?
233@@ -234,7 +234,7 @@ bool RecentRequestEntryLessThan::operator()(const RecentRequestEntry& left, cons
234 switch(column)
235 {
236 case RecentRequestsTableModel::Date:
237- return pLeft->date.toTime_t() < pRight->date.toTime_t();
238+ return pLeft->date.toSecsSinceEpoch() < pRight->date.toSecsSinceEpoch();
bool QDateTime::operator<
is not used directly, without toTimeT()/toSecsSinceEpoch()
?
13 // Earliest date that can be represented (far in the past)
14-const QDateTime TransactionFilterProxy::MIN_DATE = QDateTime::fromTime_t(0);
15+const QDateTime TransactionFilterProxy::MIN_DATE = QDateTime::fromSecsSinceEpoch(0);
16 // Last date that can be represented (far in the future)
17-const QDateTime TransactionFilterProxy::MAX_DATE = QDateTime::fromTime_t(0xFFFFFFFF);
18+const QDateTime TransactionFilterProxy::MAX_DATE = QDateTime::fromSecsSinceEpoch(std::numeric_limits<qint64>::max());
From Qt documentation [0]:
Note that there are possible values for secs that lie outside the valid range of QDateTime, both negative and positive. The behavior of this function is undefined for those values.
Anyone knows what are these “ouside” values, and is this ::max()
OK here then?
[0] https://doc.qt.io/qt-5/qdatetime.html#fromSecsSinceEpoch
25@@ -26,9 +26,9 @@ class RecentRequestEntry
26
27 SERIALIZE_METHODS(RecentRequestEntry, obj) {
28 unsigned int date_timet;
7@@ -8,6 +8,7 @@
8 #include <qt/transactionrecord.h>
9
10 #include <cstdlib>
11+#include <limits>
0./serialize.h:676:6: error: member reference base type 'long long' is not a structure or union
1 a.Unserialize(is);
2 ~^~~~~~~~~~~~
26@@ -25,10 +27,10 @@ class RecentRequestEntry
27 SendCoinsRecipient recipient;
28
29 SERIALIZE_METHODS(RecentRequestEntry, obj) {
30- unsigned int date_timet;
31- SER_WRITE(obj, date_timet = obj.date.toTime_t());
32+ qint64 date_timet;