EXSLT - date:add - Version 1

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

Function Syntax

string date:add(string, string)

The date:add function returns the date/time resulting from adding a duration to a date/time.

The first argument must be right-truncated date/time strings in one of the formats defined in [XML Schema Part 2: Datatypes]. The permitted formats are as follows:

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

The return value is a right-truncated date/time strings in one of the formats defined in [XML Schema Part 2: Datatypes] and listed above.

The date/time string passed as the first argument must be adjusted with the following steps before the duration is added to it.

  1. If the date/time string is in xs:gYear format and the duration string has a non-zero value for months, days, hours, minutes or seconds, then the date/time string is converted to xs:gYearMonth format by inserting the string -01 between the year and the time zone (if one is specified) and the next step is applied.
  2. If the date/time string is in xs:gYearMonth format and the duration string has a non-zero value for days, hours, minutes or seconds, then the date/time string is converted to xs:date format by inserting the string -01 between the month and the time zone (if one is specified) and the next step is applied.
  3. If the date/time string is in xs:date format and the duration string has a non-zero value for hours, minutes or seconds, then the date/time string is converted to xs:dateTime format by inserting the string T00:00:00 between the date and the time zone (if one is specified).

Thus, given the following call:

date:add('2001-05', 'P3D5H')

The date/time is converted to 2001-05-01T00:00:00 before the duration is added, and the result is therefore 2001-05-04T05:00:00.

On the other hand, given the following call:

date:add('2001-05', 'P3Y')

No adjustment is made to the date/time before the duration is added, and the result is therefore 2004-05.

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

Implementations

No XSLT processors that we know of have built-in support for date:add.

There are currently no third-party implementations of date:add.

Change History

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

Returns the date/time resulting from adding a duration to a date/time.

http://www.exslt.org/date/functions/add/date.add.1.html last modified 2001-05-12