After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 93444 - date:difference() failing when return value is < 0
date:difference() failing when return value is < 0
Status: VERIFIED FIXED
Product: libxslt
Classification: Platform
Component: general
unspecified
Other Solaris
: Normal normal
: ---
Assigned To: Daniel Veillard
Daniel Veillard
Depends on:
Blocks:
 
 
Reported: 2002-09-16 23:51 UTC by dburke
Modified: 2009-08-15 18:40 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description dburke 2002-09-16 23:51:48 UTC
% xsltproc --version
Using libxml 20423, libxslt 10019 and libexslt 710
xsltproc was compiled against libxml 20423, libxslt 10019 and libexslt 710
libxslt 10019 was compiled against libxml 20423
libexslt 710 was compiled against libxml 20423

With the following stylesheet/XML file (adapted from 
tests/exslt/date/difference.1.xml) I get strange output from xsltproc:

% xsltproc difference.1.xsl a.xml
difference : 1970-01-01T05:04:03 - 1970-01-01T04:03:02
result     : PT1H1M1S
difference : 2000-01-01T05:00:03 - 2000-01-01T04:03:02
result     : PT57M1S
difference : 2000-01-01T05:00:03 - 1980-01-01T04:03:02
result     : P7305DT57M1S
difference : 1970-01-01T04:03:02 - 1970-01-01T05:04:03
result     : -PT1H1M1S
difference : 2000-01-01T04:03:02 - 2000-01-01T05:00:03
result     : -PT57M1S
difference : 1980-01-01T04:03:02 - 2000-01-01T05:00:03
result     : -P-7305DT57M1S

The last three results should be the "negative" of the first three 
results, which seem okay when the day is the same but not for the last 
one, when the day is different (I expected a result of -P7305DT57M1S).

% cat a.xml
<?xml version="1.0"?>
<page>
  <!-- examples from tests/exslt/date/dfference.1.xml -->
  <date date1='1970-01-01T05:04:03' date2='1970-01-01T04:03:02'/>
  <date date1='2000-01-01T05:00:03' date2='2000-01-01T04:03:02'/>
  <date date1='2000-01-01T05:00:03' date2='1980-01-01T04:03:02'/>
  <!--* reverse some of these *-->
  <date date2='1970-01-01T05:04:03' date1='1970-01-01T04:03:02'/>
  <date date2='2000-01-01T05:00:03' date1='2000-01-01T04:03:02'/>
  <date date2='2000-01-01T05:00:03' date1='1980-01-01T04:03:02'/>
</page>

% cat difference.1.xsl
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" 
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:date="http://exslt.org/dates-and-times"
                extension-element-prefixes="date">

<xsl:output method="text"/>
<xsl:strip-space elements="*"/>

<xsl:template match="date">
<xsl:text>difference : </xsl:text><xsl:value-of select="@date1"/> - 
<xsl:value-of select="@date2"/>
<xsl:text>
</xsl:text>
<xsl:text>result     : </xsl:text><xsl:value-of 
select="date:difference(@date1,@date2)"/>
<xsl:text>
</xsl:text>
</xsl:template>

</xsl:stylesheet>
Comment 1 Daniel Veillard 2002-09-17 08:52:19 UTC
Hum, is that related to bug #92818
  http://bugzilla.gnome.org/show_bug.cgi?id=92818

Daniel
Comment 2 Daniel Veillard 2002-09-20 11:29:48 UTC
Okay Igor Zlatkovic and Charlie Bozeman have fixed this problem
in CVS, this should be in the next release,

  thanks for the report,

Daniel
Comment 3 Daniel Veillard 2002-09-26 21:50:42 UTC
Should be closed with the last release,

  thanks,

Daniel