Description
The functx:duration-from-timezone function accepts a timezone (as it appears in xs:date , xs:time , xs:dateTime etc. values) and converts it to an xs:dayTimeDuration value. The $timezone value can be Z , or in the format (+|-)HH:MM .
Arguments and Return TypeName | Type | Description |
$timezone |
xs:string |
the time zone, in (+|-)HH:MM format |
return value |
xs:dayTimeDuration |
XSLT Function DeclarationSee XQuery definition. | <xsl:function name="functx:duration-from-timezone" as="xs:dayTimeDuration"
xmlns:functx="http://www.functx.com">
<xsl:param name="timezone" as="xs:string"/>
<xsl:sequence select="
xs:dayTimeDuration(
if (not(matches($timezone,'Z|[\+\-]\d{2}:\d{2}')))
then error(xs:QName('functx:Invalid_Timezone_Value'))
else if ($timezone = 'Z')
then 'PT0S'
else replace($timezone,'\+?(\d{2}):\d{2}','PT$1H')
)
"/>
</xsl:function>
|
ExamplesXPath Example | Results |
---|
functx:duration-from-timezone('Z') |
PT0S |
functx:duration-from-timezone('-05:00') |
-PT5H |
functx:duration-from-timezone('+09:00') |
PT9H |
See AlsoHistory |
Recommended Reading:
|