home contribute faq download

FunctX XSLT Functions

functx:is-leap-year

Whether a date falls in a leap year

Google
Webdatypic.com

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

NameTypeDescription
$date xs:anyAtomicType? the date or year
return value xs:boolean

XSLT Function Declaration

See XQuery definition.
<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

XPath ExampleResults
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 Also

functx:last-day-of-monthThe last day of the month of a date

History

Published OnLast UpdatedContributor(s)
2006-06-272007-02-26Priscilla Walmsley, Datypic, pwalmsley@datypic.com, https://www.datypic.com
Datypic XSLT Services

Recommended Reading:

XQuery