home contribute faq download

FunctX XSLT Functions

fn:seconds-from-duration

The number of seconds in a duration

Google
Webdatypic.com

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 Type

NameType
$arg xs:duration?
return value xs:decimal?

Examples

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

functx:total-seconds-from-durationThe total number of seconds in a dayTimeDuration

History

Published OnLast UpdatedContributor(s)
2006-06-272007-02-26W3C, XQuery 1.0 and XPath 2.0 Functions and Operators, http://www.w3.org/TR/xpath-functions/
Datypic XSLT Services

Recommended Reading:

XQuery