summaryrefslogtreecommitdiffstats
path: root/xslt/commonTemplates.xsl
diff options
context:
space:
mode:
authorGravatar Miika Turkia <miika.turkia@gmail.com>2013-03-10 10:24:49 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-03-10 09:29:12 -0700
commit42ea5e351014994980fa0704784906b06a501eec (patch)
treeab5bc00c2627400214e5bce90866fa5448c63805 /xslt/commonTemplates.xsl
parent7c6ff9f957a1e7bfebb968cdc4bb96e2832ea4d8 (diff)
downloadsubsurface-42ea5e351014994980fa0704784906b06a501eec.tar.gz
.DLD generation for uploading to divelogs.de
This generates a .DLD file of selected dives to be uploaded to divelogs.de. The actual upload functionality along with sensible user interface is still to be implemented. However, the resulting file from this patch is tested to work (as far as I can tell) using upload API of divelogs.de. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'xslt/commonTemplates.xsl')
-rw-r--r--xslt/commonTemplates.xsl26
1 files changed, 26 insertions, 0 deletions
diff --git a/xslt/commonTemplates.xsl b/xslt/commonTemplates.xsl
index a9aa44279..cd4ee993e 100644
--- a/xslt/commonTemplates.xsl
+++ b/xslt/commonTemplates.xsl
@@ -98,4 +98,30 @@
</xsl:choose>
</xsl:template>
+ <xsl:template name="time2sec">
+ <xsl:param name="time"/>
+
+ <xsl:value-of select="substring-before($time, ':') * 60 + substring-before(substring-after($time, ':'), ' ')"/>
+ </xsl:template>
+
+ <!-- Calculate sum of all parameters, and strip any unit following the
+ value -->
+ <xsl:template name="sum">
+ <xsl:param name="values"/>
+ <xsl:param name="sum" select="'0'"/>
+
+ <xsl:variable name="value" select="substring-before($values[1], ' ')"/>
+ <xsl:choose>
+ <xsl:when test="count($values) = 1">
+ <xsl:value-of select="format-number($value + $sum, '#.#')"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="sum">
+ <xsl:with-param name="values" select="$values[position() &gt; 1]"/>
+ <xsl:with-param name="sum" select="$sum + $value"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
</xsl:stylesheet>