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 TypeName | Type | Description |
$duration |
xs:dayTimeDuration? |
the duration |
return value |
xs:decimal? |
XQuery Function DeclarationSee XSLT definition. | declare namespace functx = "http://www.functx.com";
declare function functx:total-hours-from-duration
( $duration as xs:dayTimeDuration? ) as xs:decimal? {
$duration div xs:dayTimeDuration('PT1H')
} ; |
ExamplesXQuery Example | Results |
---|
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 AlsoHistory |
Recommended Reading:
|