seconds-from-duration
The number of seconds in a duration
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.
Parameters |
Description |
---|---|
arg:numeric() |
Examples
XPath |
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 |