EXSLT - date:difference - Implementer Page

Version: 1
Status: implemented
User Page: index.html
XML Definition: date.difference.xml
Function Package: date.difference.zip

Function Syntax

string date:difference(string, string)

Template Syntax

<xsl:call-template name="date:difference">
   <xsl:with-param name="start" select="string" />
   <xsl:with-param name="end" select="string" />
</xsl:call-template>

The date:difference function returns the duration between the first date and the second date. If the first date occurs before the second date, then the result is a positive duration; if it occurs after the second date, the result is a negative duration.

The two dates must both be right-truncated date/time strings in one of the formats defined in [XML Schema Part 2: Datatypes]. The date/time with the most specific format (i.e. the least truncation) is converted into the same format as the date with the most specific format (i.e. the most truncation). The permitted formats are as follows, from most specific to least specific:

If either of the arguments is not in one of these formats, date:difference returns the empty string ('').

The difference between the date/times is returned as a string in the format defined for xs:duration in [3.2.6 duration] of [XML Schema Part 2: Datatypes].

If the date/time string with the least specific format is in either xs:gYearMonth or xs:gYear format, then the number of days, hours, minutes and seconds in the duration string must be equal to zero. (The format of the string will be PnYnM.) The number of months specified in the duration must be less than 12.

Otherwise, the number of years and months in the duration string must be equal to zero. (The format of the string will be PnDTnHnMnS.) The number of seconds specified in the duration string must be less than 60; the number of minutes must be less than 60; the number of hours must be less than 24.

An implementation of this extension function in the EXSLT date namespace must conform to the behaviour described in this document.

Implementations

Built-in support for date:difference is available in the following XSLT processors:

ProcessorProcessor VersionImplemented Version
4XSLT, from 4Suite.0.12.0a31
libxslt from Daniel Veillard et al.1.0.191

The following implementations of date:difference are available:

LanguageImplemented VersionCreatorDateDownload
EXSLT Function1Jeni Tennison2001-05-12date.difference.function.xsl
XSLT Template1Jeni Tennison2001-05-12date.difference.template.xsl
Javascript1Chris Bayes2001-06-11date.js
Msxsl1Chris Bayes2001-06-16date.msxsl.xsl

Change History

Submitted: 2001-05-12
Creator: Jeni Tennison(http://www.jenitennison.com/)

Returns the difference between two dates as a duration.

VersionModifiedByDetails
1.12001-06-11Jeni Tennison

Added implementations in Javascript, XSLT and EXSLT - Functions.

1.22001-06-16Jeni Tennison
  • Updated Javascript implementation.
  • Added Microsoft-specific stylesheet.
1.32002-08-21Craig Stewart

Added 4XSLT and libxslt implementation to the list.

1.42002-11-12Craig Stewart

Updated 4XSLT version to 0.12.0a3.

http://www.exslt.org/date/functions/difference/date.difference.html last modified 2002-11-12