money_seshu Dronamraju schrieb am 19.11.2010 um 10:20 (+0530): > > Problem description: EXSLT date:add() adds days to xs:gYearMonth/xs:gYear > incorrectly when month is January > > The following 2 expressions returns incorrect date: > <xsl:value-of select="date:add( "2001-01", "P3D" )" /> -> returns > 2001-01 > <xsl:value-of select="date:add( "2001", "P12D" )')" /> -> returns > 2001 > Ideally it should return "2001-01-04" and "2001-01-13" respectively. > > Root cause: > > In _exsltDateAdd(..,..) function ( libxslt/trunk/libexslt/date.c) > > Because the month is January(1), "if" condition will never evaluate to true, > even though the day was changed , so it never returns return type as XS_DATE > > Patch: attached. > > Please provide your comments.
I haven't tried your patch, but here's a standalone copy/paste testcase to confirm the issue: <xsl:stylesheet version="1.0" xmlns:date="http://exslt.org/dates-and-times" exclude-result-prefixes="date" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output indent="yes"/> <xsl:template match="/"> <dates-and-times> <d><xsl:value-of select="date:add( '2001-01', 'P3D' )" /></d> <d><xsl:value-of select="date:add( '2001-02', 'P3D' )" /></d> <d><xsl:value-of select="date:add( '2001-12', 'P3D' )" /></d> <d><xsl:value-of select="date:add( '2001-12', 'P30D' )" /></d> <d><xsl:value-of select="date:add( '2001-12', 'P31D' )" /></d> <d><xsl:value-of select="date:add( '2001-12', 'P32D' )" /></d> </dates-and-times> </xsl:template> </xsl:stylesheet> $ xsltproc exslt-date.xsl exslt-date.xsl <?xml version="1.0"?> <dates-and-times> <d>2001-01</d> <d>2001-02-04</d> <d>2001-12-04</d> <d>2001-12-31</d> <d>2002-01</d> <d>2002-01</d> </dates-and-times> January seems problematic indeed. $ xsltproc --version Using libxml 20707, libxslt 10126 and libexslt 815 xsltproc was compiled against libxml 20707, libxslt 10126 and libexslt 815 libxslt 10126 was compiled against libxml 20707 libexslt 815 was compiled against libxml 20707 -- Michael Ludwig _______________________________________________ xslt mailing list, project page http://xmlsoft.org/XSLT/ [email protected] http://mail.gnome.org/mailman/listinfo/xslt
