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 TypeName | Type | Description |
$date |
xs:anyAtomicType? |
the date or year |
return value |
xs:boolean |
XQuery Function DeclarationSee XSLT definition. | declare namespace functx = "http://www.functx.com";
declare function functx:is-leap-year
( $date as xs:anyAtomicType? ) as xs:boolean {
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
} ; |
ExamplesXQuery 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 |
Recommended Reading:
|