declare namespace functx = "http://www.functx.com";
declare function functx:timezone-from-duration
( $duration as xs:dayTimeDuration ) as xs:string {
if (string($duration) = ('PT0S','-PT0S'))
then 'Z'
else if (matches(string($duration),'-PT[1-9]H'))
then replace(string($duration),'PT([1-9])H','0$1:00')
else if (matches(string($duration),'PT[1-9]H'))
then replace(string($duration),'PT([1-9])H','+0$1:00')
else if (matches(string($duration),'-PT1[0-4]H'))
then replace(string($duration),'PT(1[0-4])H','$1:00')
else if (matches(string($duration),'PT1[0-4]H'))
then replace(string($duration),'PT(1[0-4])H','+$1:00')
else error(xs:QName('functx:Invalid_Duration_Value'))
} ; |