[PATCH] Handle seconds in decimal notation (from JDiveLog)

Miika Turkia miika.turkia at gmail.com
Mon Nov 26 10:57:05 PST 2012


This is a hack to convert time stored in decimal notation to proper
seconds. When using metric units the default way of JDiveLog to store
seconds is to have the amount of seconds after decimal point (1.20 is 1
minute 20 seconds). In some odd case it is reportedly possible that the
seconds are actually 100 based, thus we need to convert that to seconds
(1.33333 will become 1 minute 20 seconds).

Signed-off-by: Miika Turkia <miika.turkia at gmail.com>
---
 xslt/jdivelog2subsurface.xslt |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/xslt/jdivelog2subsurface.xslt b/xslt/jdivelog2subsurface.xslt
index 37b0dbf..4e3d5a4 100644
--- a/xslt/jdivelog2subsurface.xslt
+++ b/xslt/jdivelog2subsurface.xslt
@@ -386,7 +386,14 @@ Comment: <xsl:value-of select="Comment"/>
           <xsl:value-of select="concat(floor(number($timeSec) div 60), ':',    format-number(floor(number($timeSec) mod 60), '00'), ' min')"/>
         </xsl:when>
         <xsl:otherwise>
-          <xsl:value-of select="concat(substring-before($timeSec, '.'), ':',           format-number(substring-after($timeSec, '.'), '00'), ' min')"/>
+          <xsl:choose>
+            <xsl:when test="substring-after($timeSec, '.') >= 60">
+              <xsl:value-of select="concat(substring-before($timeSec, '.'), ':', round(substring-after(format-number($timeSec, '.00'), '.') * .6), ' min')"/>
+            </xsl:when>
+            <xsl:otherwise>
+              <xsl:value-of select="concat(substring-before($timeSec, '.'), ':', format-number(substring-after($timeSec, '.'), '00'), ' min')"/>
+            </xsl:otherwise>
+          </xsl:choose>
         </xsl:otherwise>
       </xsl:choose>
     </xsl:if>
-- 
1.7.9.5



More information about the subsurface mailing list