Permalink
Browse files

Fix a problem with ESXLT date:add() with January

Also adds a regression test provided by Michael Ludwig <milu71@gmx.de>
  • Loading branch information...
money_seshu Dronamraju authored and veillard committed Mar 7, 2011
1 parent 7f74152 commit 4e9909066731067d8e256ca25d8d54944105bc5e
Showing with 28 additions and 2 deletions.
  1. +1 −1 libexslt/date.c
  2. +1 −0 tests/docs/date_add.xml
  3. +1 −1 tests/general/Makefile.am
  4. +9 −0 tests/general/date_add.out
  5. +16 −0 tests/general/date_add.xsl
View
@@ -1577,7 +1577,7 @@ _exsltDateAdd (exsltDateValPtr dt, exsltDateValPtr dur)
if ((r->hour) || (r->min) || (r->sec))
ret->type = XS_DATETIME;
else if (ret->type != XS_DATE) {
- if ((r->mon != 1) && (r->day != 1))
+ if (r->day != 1)
ret->type = XS_DATE;
else if ((ret->type != XS_GYEARMONTH) && (r->mon != 1))
ret->type = XS_GYEARMONTH;
View
@@ -0,0 +1 @@
+<doc/>
@@ -182,7 +182,7 @@ EXTRA_DIST = \
character.out character.xsl \
character2.out character2.xsl \
itemschoose.out itemschoose.xsl \
- inner.xsl
+ inner.xsl date_add.xsl
all:
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>
+<dates-and-times>
+ <d>2001-01-04</d>
+ <d>2001-02-04</d>
+ <d>2001-12-04</d>
+ <d>2001-12-31</d>
+ <d>2002-01</d>
+ <d>2002-01-02</d>
+</dates-and-times>
View
@@ -0,0 +1,16 @@
+<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>

0 comments on commit 4e99090

Please sign in to comment.