[PATCH 1/3] Support American date format on manual CSV import
Dirk Hohndel
dirk at hohndel.org
Mon Nov 24 09:37:48 PST 2014
On Mon, Nov 24, 2014 at 07:23:14PM +0200, Miika Turkia wrote:
> Assume that date is given in American format if it contains a slash (/)
> character.
That's dangerous. I've seen people in the UK use day/month/year.
I think if all day and month values are <= 12 there is no reliable way to
tell which is which. It might be better to be able to set this in the UI.
/D
>
> Signed-off-by: Miika Turkia <miika.turkia at gmail.com>
> ---
> xslt/manualcsv2xml.xslt | 18 ++++++++++++++----
> 1 file changed, 14 insertions(+), 4 deletions(-)
>
> diff --git a/xslt/manualcsv2xml.xslt b/xslt/manualcsv2xml.xslt
> index 736b8b2..90691f4 100644
> --- a/xslt/manualcsv2xml.xslt
> +++ b/xslt/manualcsv2xml.xslt
> @@ -74,10 +74,20 @@
> <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="tempdate">
> + <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:choose>
> + <xsl:when test="substring-before($tempdate, '/') != ''">
> + <xsl:value-of select="concat(substring-after(substring-after($tempdate, '/'), '/'), '-', substring-before($tempdate, '/'), '-', substring-before(substring-after($tempdate, '/'), '/'))"/>
> + </xsl:when>
> + <xsl:otherwise>
> + <xsl:value-of select="$tempdate"/>
> + </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))"/>
> --
> 1.9.1
>
> _______________________________________________
> subsurface mailing list
> subsurface at subsurface-divelog.org
> http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface
More information about the subsurface
mailing list