home contribute faq download

FunctX XSLT Functions

functx:dayTimeDuration

Construct a dayTimeDuration from a number of days, hours, etc.

Google
Webdatypic.com

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 Type

NameTypeDescription
$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 Declaration

See 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>

Examples

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

functx:if-emptyThe first argument if it is not blank, otherwise the second argument

See Also

functx:yearMonthDurationConstruct a yearMonthDuration from a number of years and months

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