Description
The functx:yearMonthDuration function constructs an xs:yearMonthDuration value from two arguments representing a number of years and a number of months. Zero can be represented either by the number 0 or the empty sequence. If both arguments are zero or the empty sequence, it returns P0M.
Arguments and Return TypeName | Type | Description |
$years |
xs:decimal? |
the number of years |
$months |
xs:integer? |
the number of months |
return value |
xs:yearMonthDuration |
XQuery Function DeclarationSee XSLT definition. | declare namespace functx = "http://www.functx.com";
declare function functx:yearMonthDuration
( $years as xs:decimal? ,
$months as xs:integer? ) as xs:yearMonthDuration {
(xs:yearMonthDuration('P1M') * functx:if-empty($months,0)) +
(xs:yearMonthDuration('P1Y') * functx:if-empty($years,0))
} ; |
ExamplesXQuery Example | Results |
---|
functx:yearMonthDuration(1,6) |
P1Y6M |
functx:yearMonthDuration(1.5,0) |
P1Y6M |
functx:yearMonthDuration(1,()) |
P1Y |
functx:yearMonthDuration(1,0) |
P1Y |
functx:yearMonthDuration(-1,-3) |
-P1Y3M |
functx:yearMonthDuration(-1,3) |
-P9M |
functx:yearMonthDuration(0,0) |
P0M |
Depends Onfunctx:if-empty | The first argument if it is not blank, otherwise the second argument |
See AlsoHistory |
Recommended Reading:
|