diff options
author | Miika Turkia <miika.turkia@gmail.com> | 2014-11-25 19:47:04 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-11-25 13:19:49 -0800 |
commit | 1b74947bf56a2ef3b38470044d991a75ed0c5e30 (patch) | |
tree | a4b63ce2d76ee024870d5b1dc8d6039f7b391702 /xslt/manualcsv2xml.xslt | |
parent | 3b3d8949f7b3aede87fd779b314c6604020cbd16 (diff) | |
download | subsurface-1b74947bf56a2ef3b38470044d991a75ed0c5e30.tar.gz |
Allow user to select date format on manual CSV import
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'xslt/manualcsv2xml.xslt')
-rw-r--r-- | xslt/manualcsv2xml.xslt | 41 |
1 files changed, 37 insertions, 4 deletions
diff --git a/xslt/manualcsv2xml.xslt b/xslt/manualcsv2xml.xslt index 7e138d1e0..cbfb9ea14 100644 --- a/xslt/manualcsv2xml.xslt +++ b/xslt/manualcsv2xml.xslt @@ -18,6 +18,7 @@ <xsl:param name="buddyField" select="buddyField"/> <xsl:param name="notesField" select="notesField"/> <xsl:param name="weightField" select="weightField"/> + <xsl:param name="dateformat" select="dateformat"/> <xsl:output method="xml" indent="yes"/> <xsl:variable name="lf"><xsl:text> @@ -79,10 +80,42 @@ <xsl:attribute name="date"> <xsl:choose> <xsl:when test="$dateField >= 0"> - <xsl:call-template name="getFieldByIndex"> - <xsl:with-param name="index" select="$dateField"/> - <xsl:with-param name="line" select="$line"/> - </xsl:call-template> + <xsl:variable name="indate"> + <xsl:call-template name="getFieldByIndex"> + <xsl:with-param name="index" select="$dateField"/> + <xsl:with-param name="line" select="$line"/> + </xsl:call-template> + </xsl:variable> + <xsl:variable name="separator"> + <xsl:choose> + <xsl:when test="substring-before($indate, '.') != ''"> + <xsl:value-of select="'.'"/> + </xsl:when> + <xsl:when test="substring-before($indate, '-') != ''"> + <xsl:value-of select="'-'"/> + </xsl:when> + <xsl:when test="substring-before($indate, '/') != ''"> + <xsl:value-of select="'/'"/> + </xsl:when> + </xsl:choose> + </xsl:variable> + <xsl:choose> + <!-- dd.mm.yyyy --> + <xsl:when test="$datefmt = 0"> + <xsl:value-of select="concat(substring-after(substring-after($indate, $separator), $separator), '-', substring-before(substring-after($indate, $separator), $separator), '-', substring-before($indate, $separator))"/> + </xsl:when> + <!-- mm.yy.yyyy --> + <xsl:when test="$datefmt = 1"> + <xsl:value-of select="concat(substring-after(substring-after($indate, $separator), $separator), '-', substring-before($indate, $separator), '-', substring-before(substring-after($indate, $separator), $separator))"/> + </xsl:when> + <!-- yyyy.mm.dd --> + <xsl:when test="$datefmt = 2"> + <xsl:value-of select="concat(substring-before($indate, $separator), '-', substring-before(substring-after($indate, $separator), $separator), '-', substring-after(substring-after($indate, $separator), $separator))"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="'1900-1-1'"/> + </xsl:otherwise> + </xsl:choose> </xsl:when> <xsl:otherwise> <xsl:value-of select="concat(substring($date, 1, 4), '-', substring($date, 5, 2), '-', substring($date, 7, 2))"/> |