Skip to content

Commit 09575d7

Browse files
Merge pull request #177 from nathanhourt/master
Update
2 parents 3a77d86 + 2e04fd6 commit 09575d7

3 files changed

Lines changed: 9 additions & 0 deletions

File tree

VotingApp/BitsharesWalletBridge.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,8 @@ kj::Promise<void> BWB::BlockchainWalletApiImpl::getContestById(GetContestByIdCon
293293

294294
return blockPromise;
295295
}).then([context](QJsonValue block) mutable {
296+
// Contests may have a start time of zero, which indicates that they start when published. If this is the case,
297+
// set the start time to the time of publication.
296298
auto contest = context.getResults().getContest().getValue();
297299
auto timestamp = static_cast<uint64_t>(QDateTime::fromString(block.toObject()["timestamp"].toString(),
298300
Qt::ISODate).toMSecsSinceEpoch());

VotingApp/DataStructures/Contest.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
#include <QDebug>
2222
#include <QQmlEngine>
23+
#include <QTimeZone>
2324

2425
namespace swv { namespace data {
2526

@@ -34,6 +35,8 @@ void Contest::updateFields(::Contest::Reader r) {
3435
update_description(QString::fromStdString(r.getDescription()));
3536
update_name(QString::fromStdString(r.getName()));
3637
update_startTime(QDateTime::fromMSecsSinceEpoch(r.getStartTime()));
38+
// Blockchain time is UTC; update timezone to match.
39+
m_startTime.setTimeZone(QTimeZone::utc());
3740
updateContestants(r.getContestants());
3841
updateTags(r.getTags());
3942
}

VotingApp/DataStructures/DecisionRecord.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#include "Decision.hpp"
33
#include "Converters.hpp"
44

5+
#include <QTimeZone>
6+
57
namespace swv {
68
namespace data {
79

@@ -15,6 +17,8 @@ void DecisionRecord::updateFields(::DecisionRecord::Reader r) {
1517
update_voter(QString::fromStdString(r.getVoter()));
1618
update_weight(r.getWeight());
1719
update_timestamp(QDateTime::fromMSecsSinceEpoch(r.getTimestamp()));
20+
// Blockchain time is UTC; update timezone to match.
21+
m_timestamp.setTimeZone(QTimeZone::utc());
1822

1923
// Decision has a fair bit of code to parse the opinions and writeins. Just use that rather than rewrite it here.
2024
swv::data::Decision d(r.getDecision());

0 commit comments

Comments
 (0)