GNOME Bugzilla – Bug 154021
date:add-duration is buggy
Last modified: 2009-08-15 18:40:50 UTC
(This bug report has originally been made on http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=271754 , this is a copy/paste ; the original report was against 1.1.8, but I can reproduce on 1.1.10) The EXSLT function date:add-duration() produces bad values on some inputs described here. Apply the following stylesheet to any XML document (the XML input is ignored) using xsltproc to reproduce. <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:date="http://exslt.org/dates-and-times" version="1.0"> <xsl:output method="text"/> <xsl:variable name="nl"> <xsl:text> </xsl:text> </xsl:variable> <xsl:template match="/"> <xsl:variable name="myduration1" select="'-P28DT23H55M8S'"/> <xsl:variable name="myduration2" select="'-P1DT12H54M59S'"/> <xsl:value-of select="date:add-duration($myduration1, $myduration2)"/> <xsl:value-of select="$nl"/> </xsl:template> </xsl:stylesheet> The buggy output from libxslt1.1 is: -P31DT11H9M53S The correct output should be: -P30DT12H50M7S
I did some further enhancement to the date.c routines involved with negative periods, and (I hope) corrected this problem together with a similar problem in date:sum. The corrected source is in CVS (libexslt/date.c).
This should be closed by release of libxslt-1.1.15 thanks, Daniel