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 |
XSLT Function DeclarationSee XQuery definition. | <xsl:function name="functx:dayTimeDuration" as="xs:dayTimeDuration"
xmlns:functx="http://www.functx.com">
<xsl:param name="days" as="xs:decimal?"/>
<xsl:param name="hours" as="xs:decimal?"/>
<xsl:param name="minutes" as="xs:decimal?"/>
<xsl:param name="seconds" as="xs:decimal?"/>
<xsl:sequence select="
(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))
"/>
</xsl:function>
|
ExamplesXPath 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:
|