home contribute faq download

FunctX XSLT Functions

functx:total-hours-from-duration

The total number of hours in a dayTimeDuration

Google
Webdatypic.com

Description

The functx:total-hours-from-duration function returns the total number of hours in $duration. If it is an uneven number of hours, it will return a fractional part. This function is different from the built-in fn:hours-from-duration function because the latter will normalize the value and only give you the remainder number of hours between 1 and 24. For example, fn:hours-from-duration(xs:dayTimeDuration("PT26H30M")) will return 2, while functx:total-hours-from-duration(xs:dayTimeDuration("PT26H30M")) will return 26.5. If $duration is the empty sequence, the empty sequence is returned.

Arguments and Return Type

NameTypeDescription
$duration xs:dayTimeDuration? the duration
return value xs:decimal?

XSLT Function Declaration

See XQuery definition.
<xsl:function name="functx:total-hours-from-duration" as="xs:decimal?"
              xmlns:functx="http://www.functx.com">
  <xsl:param name="duration" as="xs:dayTimeDuration?"/>

  <xsl:sequence select="
   $duration div xs:dayTimeDuration('PT1H')
 "/>

</xsl:function>

Examples

XPath ExampleResults
functx:total-hours-from-duration(
     xs:dayTimeDuration('PT26H'))
26
functx:total-hours-from-duration(
     xs:dayTimeDuration('PT1H30M'))
1.5
functx:total-hours-from-duration(
     xs:dayTimeDuration('-PT3H'))
-3
functx:total-hours-from-duration(
     xs:dayTimeDuration('P1D'))
24
functx:total-hours-from-duration(
     xs:dayTimeDuration('P1DT2H'))
26

See Also

fn:hours-from-durationThe hours in a duration
functx:total-seconds-from-durationThe total number of seconds in a dayTimeDuration
functx:total-minutes-from-durationThe total number of minutes in a dayTimeDuration
functx:total-days-from-durationThe total number of days in a dayTimeDuration
functx:total-months-from-durationThe total number of months in a yearMonthDuration
functx:total-years-from-durationThe total number of years in a yearMonthDuration

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