diff --git a/common/time_utc.h b/common/time_utc.h index 0f22fa9a..b6f1488f 100644 --- a/common/time_utc.h +++ b/common/time_utc.h @@ -63,26 +63,30 @@ inline uint64_t parse_UTC_to_ms(const std::string& utc_string) { inline std::string utc_to_local_human_readable(const std::string& utc_string) { using namespace std::chrono; - uint64_t ms_since_epoch = parse_UTC_to_ms(utc_string); - auto tp = system_clock::time_point(milliseconds(ms_since_epoch)); - time_t t = system_clock::to_time_t(tp); + try { + uint64_t ms_since_epoch = parse_UTC_to_ms(utc_string); + auto tp = system_clock::time_point(milliseconds(ms_since_epoch)); + time_t t = system_clock::to_time_t(tp); - // Convert to local time - std::tm tm_local = *std::localtime(&t); + // Convert to local time + std::tm tm_local = *std::localtime(&t); - static const char* months[] = { - "January", "February", "March", "April", "May", "June", - "July", "August", "September", "October", "November", "December" - }; + static const char* months[] = { + "January", "February", "March", "April", "May", "June", + "July", "August", "September", "October", "November", "December" + }; - std::ostringstream out; - out << months[tm_local.tm_mon] << " " - << std::setw(2) << std::setfill('0') << tm_local.tm_mday << ", " - << (tm_local.tm_year + 1900) << " " - << std::setw(2) << std::setfill('0') << tm_local.tm_hour << ":" - << std::setw(2) << std::setfill('0') << tm_local.tm_min; + std::ostringstream out; + out << months[tm_local.tm_mon] << " " + << std::setw(2) << std::setfill('0') << tm_local.tm_mday << ", " + << (tm_local.tm_year + 1900) << " " + << std::setw(2) << std::setfill('0') << tm_local.tm_hour << ":" + << std::setw(2) << std::setfill('0') << tm_local.tm_min; - return out.str(); + return out.str(); + } catch (...) { + return ""; + } } #endif //JUNGFRAUJOCH_TIME_UTC_H diff --git a/reader/JFJochHDF5Reader.cpp b/reader/JFJochHDF5Reader.cpp index d2b401c4..7c380779 100644 --- a/reader/JFJochHDF5Reader.cpp +++ b/reader/JFJochHDF5Reader.cpp @@ -55,6 +55,8 @@ void JFJochHDF5Reader::ReadFile(const std::string& filename) { master_file = std::make_unique(filename); dataset->experiment = default_experiment; + dataset->arm_date = master_file->GetString("/entry/start_time"); + std::filesystem::path fsPath(filename); dataset->experiment.FilePrefix(dataset_name(filename)); diff --git a/reader/JFJochHttpReader.cpp b/reader/JFJochHttpReader.cpp index a3881d30..43d3d7ec 100644 --- a/reader/JFJochHttpReader.cpp +++ b/reader/JFJochHttpReader.cpp @@ -58,6 +58,8 @@ std::shared_ptr JFJochHttpReader::UpdateDataset_i() { return {}; auto dataset = std::make_shared(); + dataset->arm_date = msg->start_message->arm_date; + dataset->experiment = default_experiment; // JFJochReader is always using int32_t diff --git a/reader/JFJochReaderDataset.h b/reader/JFJochReaderDataset.h index 4048c2f3..a8f815fc 100644 --- a/reader/JFJochReaderDataset.h +++ b/reader/JFJochReaderDataset.h @@ -14,6 +14,8 @@ #include "../common/AzimuthalIntegration.h" struct JFJochReaderDataset { + std::string arm_date; + DiffractionExperiment experiment; PixelMask pixel_mask; diff --git a/viewer/JFJochViewerImageStatistics.cpp b/viewer/JFJochViewerImageStatistics.cpp index db7e7bbf..36d86f4e 100644 --- a/viewer/JFJochViewerImageStatistics.cpp +++ b/viewer/JFJochViewerImageStatistics.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: GPL-3.0-only #include "JFJochViewerImageStatistics.h" +#include "../common/time_utc.h" #include #include @@ -184,10 +185,12 @@ void JFJochViewerImageStatistics::loadImage(std::shared_ptrDataset().experiment; - + + text = QString("%1").arg(QString::fromStdString(exp.GetFilePrefix())); dataset_name->setText(text); - dataset_name->setToolTip(QString("Beam center: %1 %2 pxl
Detector distance: %3 mm
Energy: %4 eV
Wavelength: %5 Å") + dataset_name->setToolTip(QString("Collection data: %1
Beam center: %2 %3 pxl
Detector distance: %4 mm
Energy: %5 eV
Wavelength: %6 Å") + .arg(QString::fromStdString(utc_to_local_human_readable(image->Dataset().arm_date))) .arg(QString::number(exp.GetBeamX_pxl(), 'f', 2)) .arg(QString::number(exp.GetBeamY_pxl(), 'f', 2)) .arg(QString::number(exp.GetDetectorDistance_mm(), 'f', 3))