[vlc-commits] demux: adaptive: fix parsing of half timezone offset

Francois Cartegnie git at videolan.org
Mon Dec 28 09:53:23 UTC 2020


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Tue Dec 22 21:17:49 2020 +0100| [ca7bb743072f2aaa19c892b5e11438a9c3da0f51] | committer: Francois Cartegnie

demux: adaptive: fix parsing of half timezone offset

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ca7bb743072f2aaa19c892b5e11438a9c3da0f51
---

 modules/demux/adaptive/tools/Conversions.cpp | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/modules/demux/adaptive/tools/Conversions.cpp b/modules/demux/adaptive/tools/Conversions.cpp
index fc7434e335..6b3a8ebd73 100644
--- a/modules/demux/adaptive/tools/Conversions.cpp
+++ b/modules/demux/adaptive/tools/Conversions.cpp
@@ -133,17 +133,26 @@ UTCTime::UTCTime(const std::string &str)
         }
         else if (!in.eof() && (in.peek() == '+' || in.peek() == '-'))
         {
-            int i, tz = (in.peek() == '+') ? -60 : +60;
+            int sign = (in.peek() == '+') ? 1 : -1;
+            int tz = 0;
             in.ignore(1);
+
             if(!in.eof())
             {
-                in >> i;
-                tz *= i;
-                in.ignore(1);
-                if(!in.eof())
+                std::string tzspec;
+                in >> tzspec;
+
+                if(tzspec.length() >= 4)
+                {
+                    tz = sign * std::stoul(tzspec.substr(0, 2)) * 60;
+                    if(tzspec.length() == 5 && tzspec.find(':') == 2)
+                        tz += sign * std::stoul(tzspec.substr(3, 2));
+                    else
+                        tz += sign * std::stoul(tzspec.substr(2, 2));
+                }
+                else
                 {
-                    in >> i;
-                    tz += i;
+                    tz = sign * std::stoul(tzspec) * 60;
                 }
                 values[UTCTIME_TZ] = tz;
             }
@@ -161,7 +170,7 @@ UTCTime::UTCTime(const std::string &str)
             tm.tm_isdst = 0;
 
             int64_t mst = timegm( &tm );
-            mst += values[UTCTIME_TZ] * 60;
+            mst += values[UTCTIME_TZ] * -60;
             mst *= 1000;
             mst += values[UTCTIME_MSEC];
             t = VLC_TICK_FROM_MS(mst);



More information about the vlc-commits mailing list