summaryrefslogtreecommitdiff
path: root/qmap/livecq_parser.cpp
diff options
context:
space:
mode:
authorDave Hibberd <hibby@debian.org>2026-10-20 22:35:06 +0100
committerDave Hibberd <hibby@debian.org>2026-10-20 22:35:06 +0100
commit82ebb1ed1af30cee4dfbb1c628431d32885a00e0 (patch)
tree1a1f782d3e576b758be0bc61171574a7cd8f2376 /qmap/livecq_parser.cpp
parent061658210acb6425517733ea012dda803a7f72a1 (diff)
parent61d684922b0f1c8455cc60eb3d123df058c9e1f5 (diff)
Merge tag 'debian/3.3.0_beta2+dfsg-1' into hibbian/trixie-backports
tagging wsjtx 3.3.0~beta2+dfsg-1
Diffstat (limited to 'qmap/livecq_parser.cpp')
-rw-r--r--qmap/livecq_parser.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/qmap/livecq_parser.cpp b/qmap/livecq_parser.cpp
index e43ec5ce..6396bf9a 100644
--- a/qmap/livecq_parser.cpp
+++ b/qmap/livecq_parser.cpp
@@ -92,4 +92,32 @@ namespace QMapLiveCQ
record = parsed;
return true;
}
+
+ QDateTime spotTime(QString const& decodeTime, QDateTime const& nowUtc)
+ {
+ if ((decodeTime.size() != 4 && decodeTime.size() != 6) || !nowUtc.isValid()) {
+ return {};
+ }
+ for (auto const character : decodeTime) {
+ if (!character.isDigit()) {
+ return {};
+ }
+ }
+ QTime const time {decodeTime.mid(0, 2).toInt(), decodeTime.mid(2, 2).toInt(),
+ decodeTime.size() == 6 ? decodeTime.mid(4, 2).toInt() : 0};
+ if (!time.isValid()) {
+ return {};
+ }
+
+ auto const now = nowUtc.toUTC();
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ QDateTime result {now.date(), time, QTimeZone::UTC};
+#else
+ QDateTime result {now.date(), time, Qt::UTC};
+#endif
+ if (result > now.addSecs(60)) {
+ result = result.addDays(-1);
+ }
+ return result;
+ }
}