From 240f6db3d5f95b31ad40e7259fecc0dcf52a5b27 Mon Sep 17 00:00:00 2001 From: Phil Olynyk Date: Thu, 9 May 2019 11:08:59 -0400 Subject: [PATCH] Change UTC to LocalTime for session times --- oscar/oximeterimport.cpp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/oscar/oximeterimport.cpp b/oscar/oximeterimport.cpp index e08cf413..678344bd 100644 --- a/oscar/oximeterimport.cpp +++ b/oscar/oximeterimport.cpp @@ -442,7 +442,7 @@ void OximeterImport::on_fileImportButton_clicked() // oximodule->setStartTime( ??? ); Nope, it was set in the loader module by the file import routime on_syncButton_clicked(); } - qDebug() << "Finished file import: Oximodule startTime is " << oximodule->startTime().toString("yyyy.MM.dd HH:mm:ss"); + qDebug() << "Finished file import: Oximodule startTime is " << oximodule->startTime().toString("yyyy-MMM-dd HH:mm:ss"); } void OximeterImport::on_liveImportButton_clicked() @@ -557,13 +557,13 @@ void OximeterImport::on_stopButton_clicked() void OximeterImport::on_calendarWidget_clicked(const QDate &date) { - qDebug() << "Calendar widget clicked " << date.toString("yyyy.MM.dd"); + qDebug() << "Calendar widget clicked " << date.toString("yyyy-MMM-dd"); if (ui->radioSyncCPAP->isChecked()) { Day * day = p_profile->GetGoodDay(date, MT_CPAP); sessbar->clear(); if (day) { - QDateTime time=QDateTime::fromMSecsSinceEpoch(day->first(), Qt::UTC); + QDateTime time=QDateTime::fromMSecsSinceEpoch(day->first(), Qt::LocalTime); sessbar->clear(); QList colors; colors.push_back("#ffffe0"); @@ -580,11 +580,13 @@ void OximeterImport::on_calendarWidget_clicked(const QDate &date) ui->dateTimeEdit->setDateTime(time); } else { ui->sessbarLabel->setText(tr("No CPAP data available on %1").arg(date.toString(Qt::SystemLocaleLongDate))); + qDebug() << "Using oximeter time " << oximodule->startTime().toString("yyyy-MMM-dd hh:mm:ssap") << "on date " << date.toString(Qt::SystemLocaleLongDate); ui->dateTimeEdit->setDateTime(QDateTime(date,oximodule->startTime().time())); } sessbar->update(); } else if (ui->radioSyncOximeter) { + qDebug() << "Using oximeter date and time"; ui->sessbarLabel->setText(tr("%1").arg(date.toString(Qt::SystemLocaleLongDate))); ui->dateTimeEdit->setDateTime(QDateTime(date, ui->dateTimeEdit->dateTime().time())); } @@ -597,7 +599,8 @@ void OximeterImport::on_calendarWidget_selectionChanged() void OximeterImport::onSessionSelected(Session * session) { - QDateTime time=QDateTime::fromMSecsSinceEpoch(session->first(), Qt::UTC); + QDateTime time=QDateTime::fromMSecsSinceEpoch(session->first(), Qt::LocalTime); + qDebug() << "Selected session starts at " << time.toString("yyyy-MMM-dd hh:mm:ssap"); ui->dateTimeEdit->setDateTime(time); } @@ -607,7 +610,7 @@ void OximeterImport::on_sessionBackButton_clicked() int idx = (sessbar->selected()-1); if (idx >= 0) { sessbar->setSelected(idx); - QDateTime datetime = QDateTime::fromMSecsSinceEpoch(sessbar->session(idx)->first(), Qt::UTC); + QDateTime datetime = QDateTime::fromMSecsSinceEpoch(sessbar->session(idx)->first(), Qt::LocalTime); ui->dateTimeEdit->setDateTime(datetime); sessbar->update(); } @@ -619,7 +622,7 @@ void OximeterImport::on_sessionForwardButton_clicked() int idx = (sessbar->selected()+1); if (idx < sessbar->count()) { sessbar->setSelected(idx); - QDateTime datetime = QDateTime::fromMSecsSinceEpoch(sessbar->session(idx)->first(), Qt::UTC); + QDateTime datetime = QDateTime::fromMSecsSinceEpoch(sessbar->session(idx)->first(), Qt::LocalTime); ui->dateTimeEdit->setDateTime(datetime); sessbar->update(); } @@ -639,7 +642,7 @@ void OximeterImport::on_radioSyncOximeter_clicked() ui->syncCPAPGroup->setVisible(false); if ( oximodule ) { if (oximodule->isStartTimeValid()) { - qDebug() << "Oximeter time is valid " << oximodule->startTime().toString(); + qDebug() << "Oximeter time is valid " << oximodule->startTime().toString("yyyy-MMM-dd HH:mm:ssap"); ui->calendarWidget->setSelectedDate(oximodule->startTime().date()); ui->dateTimeEdit->setDateTime(oximodule->startTime()); } else @@ -781,7 +784,7 @@ void OximeterImport::on_syncButton_clicked() qCritical() << "OximeterImport::on_syncButton_clicked called when oximodule is null"; return; } - qDebug() << "Oximodule Start Time is " << oximodule->startTime().toString("yyyy.MM.dd HH.mm.ss") << "Duration: " << oximodule->getDuration(/* dummy */ 0 ); + qDebug() << "Oximodule Start Time is " << oximodule->startTime().toString("yyyy-MMM-dd HH.mm.ss") << "Duration: " << oximodule->getDuration(/* dummy */ 0 ); ui->stackedWidget->setCurrentWidget(ui->syncPage); @@ -792,7 +795,7 @@ void OximeterImport::on_syncButton_clicked() QDate last = p_profile->LastDay(); QDate oxidate = oximodule->startTime().date(); - qDebug() << "Oximodule start date is " << oximodule->startTime().date().toString("yyyy.MM.dd"); + qDebug() << "Oximodule start date is " << oxidate.toString("yyyy-MMM-dd"); if ((oxidate >= first) && (oxidate <= last)) { @@ -1141,14 +1144,14 @@ void OximeterImport::setInformation() void OximeterImport::on_oximeterType_currentIndexChanged(int index) { switch (index) { - case 0: //New CMS50's + case 0: // New CMS50's version 7 protocol ui->directImportButton->setEnabled(true); ui->liveImportButton->setEnabled(false); ui->fileImportButton->setEnabled(true); ui->oldCMS50specific->setVisible(false); ui->newCMS50settingsPanel->setVisible(true); break; - case 1: + case 1: // Olds CMS50's ui->directImportButton->setEnabled(true); ui->liveImportButton->setEnabled(true); ui->fileImportButton->setEnabled(true);