[gnome-maps] resrobot: Support duration with days part



commit 6a87d40d6effde52933328c5a776a81b9f1476b0
Author: Marcus Lundblad <ml update uu se>
Date:   Thu Nov 14 21:57:40 2019 +0100

    resrobot: Support duration with days part
    
    The ISO duration expressions can contain
    a day part, like P1DT2H24M.

 src/transitplugins/resrobot.js | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/src/transitplugins/resrobot.js b/src/transitplugins/resrobot.js
index 532e905f..5d38bb2b 100644
--- a/src/transitplugins/resrobot.js
+++ b/src/transitplugins/resrobot.js
@@ -45,7 +45,7 @@ const API_VERSION = 'v2';
 // Timezone for timestamps returned by this provider
 const NATIVE_TIMEZONE = 'Europe/Stockholm';
 
-const ISO_8601_DURATION_REGEXP = new RegExp(/PT((\d+)H)?((\d+)M)?/);
+const ISO_8601_DURATION_REGEXP = new RegExp(/P((\d+)D)?T((\d+)H)?((\d+)M)?/);
 
 const Products = {
     EXPRESS_TRAIN:  2,
@@ -372,9 +372,9 @@ var Resrobot = class Resrobot {
         let match = duration.match(ISO_8601_DURATION_REGEXP);
 
         if (match) {
-            let [,,h,,min] = match;
+            let [,,d,,h,,min] = match;
 
-            return (h || 0) * 3600 + (min || 0) * 60;
+            return (d || 0) * 86400 + (h || 0) * 3600 + (min || 0) * 60;
         } else {
             Utils.debug('Unknown duration: ' + duration);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]