Description
The functx:is-leap-year function returns true if $date falls in a leap year.
The first four characters of the string value of $date must be the year. For example, the argument can be a value of type xs:date, xs:dateTime, or an xs:integer with four significant digits, or an xs:string or untyped value of the form YYYY or YYYY-MM-DD.
Arguments and Return Type| Name | Type | Description |
$date |
xs:anyAtomicType? |
the date or year |
| return value |
xs:boolean |
XSLT Function Declaration| See XQuery definition. | | XSLT 2.0 Syntax: |
|---|
<xsl:function name="functx:is-leap-year" as="xs:boolean"
xmlns:functx="http://www.functx.com" >
<xsl:param name="date" as="xs:anyAtomicType?"/>
<xsl:sequence select="
for $year in xs:integer(substring(string($date),1,4))
return ($year mod 4 = 0 and
$year mod 100 != 0) or
$year mod 400 = 0
"/>
</xsl:function>
|
Examples| XSLT Example | Results |
|---|
functx:is-leap-year(xs:date('2004-01-23'))
|
true
|
functx:is-leap-year(2004)
|
true
|
functx:is-leap-year('2005-02-15')
|
false
|
See AlsoHistory |
|