XPath/XQuery add-dayTimeDuration-to-time function

Summary

Returns the xs:time value that is a given duration after a specified xs:time (or before, if the duration is negative or causes wrap-around past midnight)

Operator Mapping

Defines the semantics of the "+" operator when applied to an xs:time and an xs:dayTimeDuration value.

Signature

op:add-dayTimeDuration-to-time(
$arg1 as xs:time,
$arg2 as xs:dayTimeDuration
) as xs:time

Rules

First, the days component in the canonical lexical representation of $arg2 is set to zero (0) and the value of the resulting xs:dayTimeDuration is calculated. Alternatively, the value of $arg2 modulus 86,400 is used as the second argument. This value is added to the value of $arg1 converted to an xs:dateTime using a reference date such as 1972-12-31, and the time component of the result is returned. Note that the xs:time returned may occur in a following or preceding day and may be less than $arg1.

The result has the same timezone as $arg1. If $arg1 has no timezone, the result has no timezone.

Examples

The expression op:add-dayTimeDuration-to-time(xs:time("11:12:00"), xs:dayTimeDuration("P3DT1H15M")) returns xs:time("12:27:00").

The expression op:add-dayTimeDuration-to-time(xs:time("23:12:00+03:00"), xs:dayTimeDuration("P1DT3H15M")) returns xs:time("02:27:00+03:00").