raven/base/libmygpo-qt/0005-Fix-parsing-of-timestamp-for-EpisodeAction.patch

35 lines
1.5 KiB
Diff

From dab4844b8c516e99805b88f02df69e1b0bc11da2 Mon Sep 17 00:00:00 2001
From: Bart De Vries <bart@mogwai.be>
Date: Wed, 28 Jul 2021 23:33:43 +0200
Subject: [PATCH 05/10] Fix parsing of timestamp for EpisodeAction
I don't know the entire history of the API, but the current timestamp
that is returned by gpodder.net is in ISO 8601 format. The libmygpo-qt
implementation was trying to convert this string directly into
qulonglong which would fail, and therefore always return 0.
Presumably, the timestamp was previously returned as seconds-since-epoch,
but changed at some point in time.
---
src/EpisodeAction.cpp | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/EpisodeAction.cpp b/src/EpisodeAction.cpp
index 95536be..59aa96b 100644
--- a/src/EpisodeAction.cpp
+++ b/src/EpisodeAction.cpp
@@ -118,7 +118,10 @@ bool EpisodeActionPrivate::parse( const QVariant& data )
if( episodeActionMap.contains( QLatin1String( "timestamp" ) ) )
{
s = episodeActionMap.value( QLatin1String( "timestamp" ) );
- m_timestamp = s.toULongLong();
+ // timestamp is provided in ISO 8601 format, to be converted to qulonglong
+ // when the server generates the timestamp, it will contain extra
+ // sub-second resolution, which we need to cut off first before converting
+ m_timestamp = static_cast<qulonglong>(QDateTime::fromString(s.toString().section(QLatin1String("."), 0, 0), QLatin1String("yyyy-MM-dd'T'hh:mm:ss")).toMSecsSinceEpoch() / 1000);
}
else
{
--
2.47.0