[PATCH] Fix UDCF import time unit in timedepthmode

Miika Turkia miika.turkia at gmail.com
Sat Dec 26 23:07:02 PST 2015


The timedepthmode specifies the time in seconds when using si units,
otherwise minutes. This patch implements this support.

Fixes #981

Signed-off-by: Miika Turkia <miika.turkia at gmail.com>
---
 xslt/udcf.xslt | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/xslt/udcf.xslt b/xslt/udcf.xslt
index 62cee55..623273b 100644
--- a/xslt/udcf.xslt
+++ b/xslt/udcf.xslt
@@ -90,13 +90,24 @@
 
 	<!-- samples recorded at irregular internal, but storing time stamp -->
 	<xsl:when test="timedepthmode">
+          <xsl:variable name="timeconvert">
+            <xsl:choose>
+              <xsl:when test="//units = 'si'">
+                <xsl:value-of select="60"/>
+              </xsl:when>
+              <xsl:otherwise>
+                <xsl:value-of select="1"/>
+              </xsl:otherwise>
+            </xsl:choose>
+          </xsl:variable>
+          <debug name="{$timeconvert}"/>
 	  <!-- gas change -->
 	  <xsl:for-each select="SAMPLES/SWITCH|samples/switch">
 	    <event name="gaschange">
 	      <xsl:variable name="timeSec" select="following-sibling::T|following-sibling::t"/>
 	      <xsl:attribute name="time">
-		<xsl:value-of select="concat(floor($timeSec div 60), ':',
-		  format-number(floor($timeSec mod 60), '00'), ' min')"/>
+		<xsl:value-of select="concat(floor($timeSec div $timeconvert), ':',
+		  format-number(floor($timeSec mod $timeconvert), '00'), ' min')"/>
 	      </xsl:attribute>
 	      <xsl:attribute name="value">
 		<xsl:value-of select="ancestor::DIVE/GASES/MIX[MIXNAME=current()]/O2|ancestor::dive/gases/mix[mixname=current()]/o2 * 100" />
@@ -110,8 +121,8 @@
 	    <sample>
 	      <xsl:variable name="timeSec" select="preceding-sibling::T[position()=1]|preceding-sibling::t[position()=1]"/>
 	      <xsl:attribute name="time">
-		<xsl:value-of select="concat(floor($timeSec div 60), ':',
-		  format-number(floor($timeSec mod 60), '00'), ' min')"/>
+		<xsl:value-of select="concat(floor($timeSec div $timeconvert), ':',
+		  format-number(floor($timeSec mod $timeconvert), '00'), ' min')"/>
 	      </xsl:attribute>
 	      <xsl:attribute name="depth">
 		<xsl:value-of select="concat(., ' m')"/>
-- 
2.5.0



More information about the subsurface mailing list