functx:is-leap-year

Whether a date falls in a leap year

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.

Parameters

Description

date:date()

the date or year

Examples

XPath

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

In a generator

Copy the snippet below and paste it in Freemapper, under a language node inside the generators element. Each line of the pattern prints the result of one example; to see them, run mi generate <project> <language> example-functx-is-leap-year.

[e] example-functx-is-leap-year
    [e] start
        [e] match
            [v] /
        [e] body
            [e] write-pattern
                [v] examples
    [e] patterns
        [e] examples
            [v] E01: {{ functx:is-leap-year(xs:date('2004-01-23')) }}
            [v] E02: {{ functx:is-leap-year(2004) }}
            [v] E03: {{ functx:is-leap-year('2005-02-15') }}

See Also