From 5b65a4cc471bbe7e77209fd4cbaf3b301b23d8ce 2017-08-02 15:12:50 From: Alexandre Leroux Date: 2017-08-02 15:12:50 Subject: [PATCH] Uses DateUtils --- diff --git a/core/include/Data/SqpDateTime.h b/core/include/Data/SqpDateTime.h index 3ea0484..450e9eb 100644 --- a/core/include/Data/SqpDateTime.h +++ b/core/include/Data/SqpDateTime.h @@ -3,9 +3,9 @@ #include -#include #include +#include #include /** @@ -30,10 +30,9 @@ struct SqpDateTime { inline QDebug operator<<(QDebug d, SqpDateTime obj) { - auto tendDateTimeStart = QDateTime::fromMSecsSinceEpoch(obj.m_TStart * 1000); - auto tendDateTimeEnd = QDateTime::fromMSecsSinceEpoch(obj.m_TEnd * 1000); + auto tendDateTimeStart = DateUtils::dateTime(obj.m_TStart); + auto tendDateTimeEnd = DateUtils::dateTime(obj.m_TEnd); - // QDebug << "ts: " << tendDateTimeStart << " te: " << tendDateTimeEnd; d << "ts: " << tendDateTimeStart << " te: " << tendDateTimeEnd; return d; } diff --git a/core/src/Variable/VariableModel.cpp b/core/src/Variable/VariableModel.cpp index 75a3387..6b929c3 100644 --- a/core/src/Variable/VariableModel.cpp +++ b/core/src/Variable/VariableModel.cpp @@ -1,9 +1,10 @@ #include #include +#include + #include -#include #include #include @@ -150,8 +151,8 @@ QVariant VariableModel::data(const QModelIndex &index, int role) const if (role == Qt::DisplayRole) { if (auto variable = impl->m_Variables.at(index.row()).get()) { /// Lambda function that builds the variant to return for a time value - auto dateTimeVariant = [](double time) { - auto dateTime = QDateTime::fromMSecsSinceEpoch(time * 1000.); + auto dateTimeVariant = [](double secs) { + auto dateTime = DateUtils::dateTime(secs); return dateTime.toString(DATETIME_FORMAT); }; diff --git a/gui/src/TimeWidget/TimeWidget.cpp b/gui/src/TimeWidget/TimeWidget.cpp index e2a754d..79a0146 100644 --- a/gui/src/TimeWidget/TimeWidget.cpp +++ b/gui/src/TimeWidget/TimeWidget.cpp @@ -40,9 +40,8 @@ TimeWidget::~TimeWidget() void TimeWidget::onTimeUpdateRequested() { - auto dateTime = SqpDateTime{ - static_cast(ui->startDateTimeEdit->dateTime().toMSecsSinceEpoch() / 1000.), - static_cast(ui->endDateTimeEdit->dateTime().toMSecsSinceEpoch()) / 1000.}; + auto dateTime = SqpDateTime{DateUtils::secondsSinceEpoch(ui->startDateTimeEdit->dateTime()), + DateUtils::secondsSinceEpoch(ui->endDateTimeEdit->dateTime())}; emit timeUpdated(std::move(dateTime)); } diff --git a/plugins/amda/src/AmdaProvider.cpp b/plugins/amda/src/AmdaProvider.cpp index bfc0f46..ccb5456 100644 --- a/plugins/amda/src/AmdaProvider.cpp +++ b/plugins/amda/src/AmdaProvider.cpp @@ -2,6 +2,7 @@ #include "AmdaDefs.h" #include "AmdaResultParser.h" +#include #include #include #include @@ -31,7 +32,7 @@ const auto AMDA_TIME_FORMAT = QStringLiteral("yyyy-MM-ddThh:mm:ss"); /// Formats a time to a date that can be passed in URL QString dateFormat(double sqpDateTime) noexcept { - auto dateTime = QDateTime::fromMSecsSinceEpoch(sqpDateTime * 1000.); + auto dateTime = DateUtils::dateTime(sqpDateTime); return dateTime.toString(AMDA_TIME_FORMAT); }