http://www.w3.org/1999/XSL/Transform

c.dateWithin ([currentDate : datetime], dateFrom : datetime, dateUntil : string) : boolean

The function dateWithin checks, if the current date is within a given date range. The range is specified by the arguments dateFrom and dateUntil. One of these arguments may be empty to express an infinite start or end point.

To examine a specific date use the optional argument currentDate.

If the function dateWithin is called without a specific date a time dependency is created to the date, when the return value of dateWithin changes. For example if this method is executed at 2 PM to check if the current time is between 3 PM and 5 PM, the computed result will automatically become invalidated at 3 PM, because this method would most likely return a different result.

<xsl:if test="c.dateWithin('2007-01-01T12:00:00', '2007-01-01T14:00:00')"> ... </xsl:if>
Conditional output in a date range

The following example filters a number of objects based on their validity period.

<xsl:stylesheet version="1.0">
<xsl:template match="/">
<xsl:variable name="items" c.as="Node">
<item validFrom="2010-01-01T00:00:00" validUntil="2011-01-01T00:00:00" name="Element A" />
<item validFrom="2050-07-01T00:00:00" name="Element B" />
<item validUntil="2012-08-01T00:00:00" name="Element C" />
<item name="Element D" />
</xsl:variable>
<xsl:for-each select="$items/item[c.dateWithin(@validFrom, @validUntil)]"> Valid element:
<xsl:value-of select="@name" />
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Filter items based on validity period

The execution of the method at March 3rd 2006 will produce the following output:

Valid element: Element A
Valid element: Element C
Valid element: Element D

  1. Das Element A wird als gültig erklärt, da es der Gültigkeitszeitraum auf das ganze Jahr beschränkt ist.
  2. Das Element B ist ungültig, da es erst ab dem 01.07.2050 gültig ist. Die fehlende Angabe des validUntil-Attributs führt zu einer unbegrenzten Gültigkeit ab diesem Zeitpunkt
  3. Das Element C ist gültig, da es erst zum 01.08.2012 ungültig wird.
  4. Das Element D ist immer gültig, da es keinen Gültigkeitszeitraum beschreibt