diff options
| author | Christoph Berg <myon@debian.org> | 2026-10-09 14:12:49 +0200 |
|---|---|---|
| committer | Christoph Berg <myon@debian.org> | 2026-10-09 14:12:49 +0200 |
| commit | 76956486fa7ef52a51d4e56df1e13a9f19a6c93c (patch) | |
| tree | fe0c394439fdc167d1970372e8998874090854dd /qmap/livecq_parser.cpp | |
| parent | 0685fcada9f95fe90f70b387cd7d757da8209624 (diff) | |
| parent | ffc62c792c9a5196cb4ce7a353287dfe20db6524 (diff) | |
Update upstream source from tag 'upstream/3.3.0_beta1+dfsg'
Update to upstream version '3.3.0~beta1+dfsg'
with Debian dir 85037bbb9376721108594b59b54ead82ac6924a3
Diffstat (limited to 'qmap/livecq_parser.cpp')
| -rw-r--r-- | qmap/livecq_parser.cpp | 28 |
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; + } } |
