Description
The functx:dayTimeDuration function constructs an xs:dayTimeDuration value from arguments representing the number of days, hours, minutes and seconds. Zero can be represented either by the number 0 or the empty sequence. If all arguments are zero or the empty sequence, it returns P0M.
Arguments and Return TypeName | Type | Description |
$days |
xs:decimal? |
the number of days |
$hours |
xs:decimal? |
the number of hours |
$minutes |
xs:decimal? |
the number of minutes |
$seconds |
xs:decimal? |
the number of seconds |
return value |
xs:dayTimeDuration |
XQuery Function DeclarationSee XSLT definition. | declare namespace functx = "http://www.functx.com";
declare function functx:dayTimeDuration
( $days as xs:decimal? ,
$hours as xs:decimal? ,
$minutes as xs:decimal? ,
$seconds as xs:decimal? ) as xs:dayTimeDuration {
(xs:dayTimeDuration('P1D') * functx:if-empty($days,0)) +
(xs:dayTimeDuration('PT1H') * functx:if-empty($hours,0)) +
(xs:dayTimeDuration('PT1M') * functx:if-empty($minutes,0)) +
(xs:dayTimeDuration('PT1S') * functx:if-empty($seconds,0))
} ; |
ExamplesXQuery Example | Results |
---|
functx:dayTimeDuration(1,6,0,0) |
P1DT6H |
functx:dayTimeDuration(2.5,0,0,0) |
P2DT12H |
functx:dayTimeDuration(1,(),3,5.6) |
P1DT3M5.6S |
functx:dayTimeDuration(0,0,5,0) |
PT5M |
functx:dayTimeDuration(0,0,0,0) |
PT0S |
Depends Onfunctx:if-empty | The first argument if it is not blank, otherwise the second argument |
See AlsoHistory |
Recommended Reading:
|