@@ -24,6 +24,9 const auto RESULT_LINE_SEPARATOR = QRegularExpression{QStringLiteral("\\s+")}; | |||||
24 | /// the file |
|
24 | /// the file | |
25 | const auto DATA_HEADER_REGEX = QRegularExpression{QStringLiteral("#\\s*DATA\\s*:")}; |
|
25 | const auto DATA_HEADER_REGEX = QRegularExpression{QStringLiteral("#\\s*DATA\\s*:")}; | |
26 |
|
26 | |||
|
27 | /// Format for dates in result files | |||
|
28 | const auto DATE_FORMAT = QStringLiteral("yyyy-MM-ddThh:mm:ss.zzz"); | |||
|
29 | ||||
27 | /// Regex to find unit in a line. Examples of valid lines: |
|
30 | /// Regex to find unit in a line. Examples of valid lines: | |
28 | /// ... PARAMETER_UNITS : nT ... |
|
31 | /// ... PARAMETER_UNITS : nT ... | |
29 | /// ... PARAMETER_UNITS:nT ... |
|
32 | /// ... PARAMETER_UNITS:nT ... | |
@@ -31,12 +34,21 const auto DATA_HEADER_REGEX = QRegularExpression{QStringLiteral("#\\s*DATA\\s*: | |||||
31 | /// ... PARAMETER_UNITS : m/s ... |
|
34 | /// ... PARAMETER_UNITS : m/s ... | |
32 | const auto UNIT_REGEX = QRegularExpression{QStringLiteral("\\s*PARAMETER_UNITS\\s*:\\s*(.+)")}; |
|
35 | const auto UNIT_REGEX = QRegularExpression{QStringLiteral("\\s*PARAMETER_UNITS\\s*:\\s*(.+)")}; | |
33 |
|
36 | |||
|
37 | QDateTime dateTimeFromString(const QString &stringDate) noexcept | |||
|
38 | { | |||
|
39 | #if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0) | |||
|
40 | return QDateTime::fromString(stringDate, Qt::ISODateWithMs); | |||
|
41 | #else | |||
|
42 | return QDateTime::fromString(stringDate, DATE_FORMAT); | |||
|
43 | #endif | |||
|
44 | } | |||
|
45 | ||||
34 | /// Converts a string date to a double date |
|
46 | /// Converts a string date to a double date | |
35 | /// @return a double that represents the date in seconds, NaN if the string date can't be converted |
|
47 | /// @return a double that represents the date in seconds, NaN if the string date can't be converted | |
36 | double doubleDate(const QString &stringDate) noexcept |
|
48 | double doubleDate(const QString &stringDate) noexcept | |
37 | { |
|
49 | { | |
38 | // Format: yyyy-MM-ddThh:mm:ss.zzz |
|
50 | // Format: yyyy-MM-ddThh:mm:ss.zzz | |
39 |
auto dateTime = |
|
51 | auto dateTime = dateTimeFromString(stringDate); | |
40 | dateTime.setTimeSpec(Qt::UTC); |
|
52 | dateTime.setTimeSpec(Qt::UTC); | |
41 | return dateTime.isValid() ? DateUtils::secondsSinceEpoch(dateTime) |
|
53 | return dateTime.isValid() ? DateUtils::secondsSinceEpoch(dateTime) | |
42 | : std::numeric_limits<double>::quiet_NaN(); |
|
54 | : std::numeric_limits<double>::quiet_NaN(); |
General Comments 0
You need to be logged in to leave comments.
Login now