Date operations on xsl 1.0
Solution 1:
Adding/subtracting number of days to/from date in pure XSLT 1.0:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:param name="givenDate" select="'2014-05-13T00:00:00'"/>
<xsl:param name="daysDiff" select="-3"/>
<xsl:variable name="JDN">
<xsl:call-template name="JDN">
<xsl:with-param name="date" select="$givenDate" />
</xsl:call-template>
</xsl:variable>
<xsl:variable name="newDate">
<xsl:call-template name="GD">
<xsl:with-param name="JDN" select="$JDN + $daysDiff" />
</xsl:call-template>
</xsl:variable>
<xsl:template match="/">
<output>
<GivenDate><xsl:value-of select="$givenDate"/></GivenDate>
<NewDate><xsl:value-of select="$newDate"/></NewDate>
</output>
</xsl:template>
<xsl:template name="JDN">
<xsl:param name="date"/>
<xsl:param name="year" select="substring($date, 1, 4)"/>
<xsl:param name="month" select="substring($date, 6, 2)"/>
<xsl:param name="day" select="substring($date, 9, 2)"/>
<xsl:param name="a" select="floor((14 - $month) div 12)"/>
<xsl:param name="y" select="$year + 4800 - $a"/>
<xsl:param name="m" select="$month + 12*$a - 3"/>
<xsl:value-of select="$day + floor((153*$m + 2) div 5) + 365*$y + floor($y div 4) - floor($y div 100) + floor($y div 400) - 32045" />
</xsl:template>
<xsl:template name="GD">
<xsl:param name="JDN"/>
<xsl:param name="f" select="$JDN + 1401 + floor((floor((4 * $JDN + 274277) div 146097) * 3) div 4) - 38"/>
<xsl:param name="e" select="4*$f + 3"/>
<xsl:param name="g" select="floor(($e mod 1461) div 4)"/>
<xsl:param name="h" select="5*$g + 2"/>
<xsl:param name="D" select="floor(($h mod 153) div 5 ) + 1"/>
<xsl:param name="M" select="(floor($h div 153) + 2) mod 12 + 1"/>
<xsl:param name="Y" select="floor($e div 1461) - 4716 + floor((14 - $M) div 12)"/>
<xsl:param name="MM" select="substring(100 + $M, 2)"/>
<xsl:param name="DD" select="substring(100 + $D, 2)"/>
<xsl:value-of select="concat($Y, '-', $MM, '-', $DD)" />
</xsl:template>
</xsl:stylesheet>
Result:
<?xml version="1.0" encoding="UTF-8"?>
<output>
<GivenDate>2014-05-13T00:00:00</GivenDate>
<NewDate>2014-05-10</NewDate>
</output>
--
Note that the givenDate's parameter value is a string and as such must be wrapped in single quotes.