GNOME Bugzilla – Bug 153000
Date has problems with time zones
Last modified: 2009-08-15 18:40:50 UTC
As an example, the differences of times computed below are obviously wrong (+04:00 and -04:00 are mixed up). More annoying, the function date:seconds(), which should return the same value as time(NULL), may be wrong when date:date-time() returns a non GMT date...). [pesenti@dev vivisimo]$ cat /tmp/a.xsl <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:date="http://exslt.org/dates-and-times" extension-element-prefixes="date" > <xsl:template match="/"> <xsl:value-of select="date:difference('1970-01-01T00:00:00+04:00', '1970-01-01T04:00:00Z')"/> <br/> <xsl:value-of select="date:difference('1970-01-01T00:00:00-04:00', '1970-01-01T04:00:00Z')"/> </xsl:template> </xsl:stylesheet> [pesenti@dev vivisimo]$ xsltproc /tmp/a.xsl /tmp/a.xsl <?xml version="1.0"?> P0D<br/>PT8H [pesenti@dev vivisimo]$ cat /tmp/b.xsl <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:date="http://exslt.org/dates-and-times" extension-element-prefixes="date" > <xsl:template match="/"> <xsl:value-of select="date:seconds()"/> </xsl:template> </xsl:stylesheet> [pesenti@dev vivisimo]$ xsltproc /tmp/b.xsl /tmp/b.xsl <?xml version="1.0"?> 1095485514 [pesenti@dev vivisimo]$ date +'%s' 1095514317 [pesenti@dev vivisimo]$ [pesenti@dev vivisimo]$ xsltproc --version Using libxml 20611, libxslt 10108 and libexslt 806 xsltproc was compiled against libxml 20611, libxslt 10108 and libexslt 806 libxslt 10108 was compiled against libxml 20611 libexslt 806 was compiled against libxml 20611
I agree with your analysis. Apparently our library code had a (consistent) problem with timezone offset (a single line within the time "normalization" routine), but I hope I have it right now: bill@bbrack bug153000 $ ./xsltproc a.xsl a.xsl <?xml version="1.0"?> PT8H<br/>P0D bill@bbrack bug153000 $ ./xsltproc b.xsl b.xsl; date +'%s' <?xml version="1.0"?> 1095551331 1095551331 Thanks for the clear report, and for the testing scripts. I'm going to post something to the xsl mailing list advising people of the change I have made in case someone disagrees with it, but I really don't expect that to happen. The fixed code (libexslt/date.c) is in CVS. Bill
*** Bug 153425 has been marked as a duplicate of this bug. ***
The release of libxslt-1.1.11 should fix this, thanks, Daniel