Description
The fn:seconds-from-duration function calculates the seconds component of a normalized xs:duration value, as a decimal number between -60 and 60 exclusive. This is not necessarily the same as the number that appears before the S in the value. For example, if the duration is PT90S , the function returns 30 rather than 90. This is because 60 of those seconds are considered to be one minute, and the normalized value would therefore be PT1M30S .
For a function that returns the total number of seconds as a decimal number, see functx:total-seconds-from-duration.
This description is © Copyright 2007, Priscilla Walmsley. It is excerpted from the book XQuery by Priscilla Walmsley, O'Reilly, 2007. For a complete explanation of this function, please refer to Appendix A of the book. Arguments and Return TypeName | Type |
$arg |
xs:duration? |
return value |
xs:decimal? |
ExamplesXPath Example | Results |
---|
seconds-from-duration(
xs:dayTimeDuration('PT30.5S')) |
30.5 |
seconds-from-duration(
xs:dayTimeDuration('-PT90.5S')) |
-30.5 |
seconds-from-duration(
xs:dayTimeDuration('PT1M')) |
0 |
seconds-from-duration(
xs:dayTimeDuration('PT60S')) |
0 |
See AlsoHistory |
Recommended Reading:
|