EXSLT - date:add-duration - Version 2

Version: 2
Status: implemented
User Page: index.html
XML Definition: date.add-duration.xml
Function Package: date.add-duration.zip

Function Syntax

string date:add-duration(string, string)

Template Syntax

<xsl:call-template name="date:add-duration">
   <xsl:with-param name="duration1" select="string" />
   <xsl:with-param name="duration2" select="string" />
</xsl:call-template>

The date:add-duration function returns the duration resulting from adding two durations together.

Both arguments are strings in the format defined for xs:duration in [3.2.6 duration] of [XML Schema Part 2: Datatypes]. If either argument is not in this format, the function returns an empty string ('').

The return value is a string in the format defined for xs:duration in [3.2.6 duration] of [XML Schema Part 2: Datatypes].

The durations can usually be added by summing the numbers given for each of the components in the durations. However, if the durations are differently signed, then this sometimes results in durations that are impossible to express in this syntax (e.g. 'P1M' + '-P1D'). In these cases, the function returns an empty string ('').

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:add-duration is available in the following XSLT processors:

ProcessorProcessor VersionImplemented Version
libxslt from Daniel Veillard et al.1.0.192

The following implementations of date:add-duration are available:

LanguageImplemented VersionCreatorDateDownload
EXSLT Function2Jeni Tennison2001-06-11date.add-duration.function.xsl
XSLT Template2Jeni Tennison2001-06-11date.add-duration.template.xsl
Javascript2Chris Bayes2001-06-11date.js
Msxsl2Chris Bayes2001-06-16date.msxsl.xsl

Change History

Previous Version: date.add-duration.1.html

VersionModifiedByDetails
22001-06-11Jeni Tennison
  • Made it illegal to have an addition result in positive (years and) months and negative (days, hours, minutes and) seconds, or vice versa.
  • Added implementations in Javascript, XSLT and EXSLT - Functions.
2.12001-06-16Jeni Tennison
  • Updated Javascript implementation.
  • Added Microsoft-specific stylesheet.
2.22002-08-21Craig Stewart

Added libxslt implementation to the list.

http://www.exslt.org/date/functions/add-duration/date.add-duration.2.html last modified 2002-08-21