fn:seconds-from-duration

Returns the number of seconds in a duration.

Signature

fn:seconds-from-duration($arg as xs:duration?) as xs:decimal?

Properties

This function is deterministic, context-independent, and focus-independent.

Rules

If $arg is the empty sequence, the function returns the empty sequence.

Otherwise, the function returns an xs:decimal representing the seconds component in the value of $arg. Given that a duration is a ($months, $seconds) tuple, the result is the value of ($seconds mod 60) as an xs:decimal.

If $arg is a negative duration then the result will be negative.

If $arg is an xs:yearMonthDuration the function returns 0.

Examples

The expression fn:seconds-from-duration(xs:dayTimeDuration("P3DT10H12.5S")) returns 12.5.

The expression fn:seconds-from-duration(xs:dayTimeDuration("-PT256S")) returns -16.0.