home contribute faq download

FunctX XSLT Functions

functx:time

Construct a time from an hour, minute and second

Google
Webxsltfunctions.com

Description

The functx:time function constructs an xs:time value from arguments representing the hour, minute and second. The arguments can have any type that can be cast to xs:integer. If the combination does not result in a valid time (e.g. the hour is 25 or the minute is 61), an error is raised. The function does not currently support decimal numbers for $second.

Arguments and Return Type

NameTypeDescription
$hour xs:anyAtomicType the hour
$minute xs:anyAtomicType the minute
$second xs:anyAtomicType the second
return value xs:time

XSLT Function Declaration

See XQuery definition.
<xsl:function name="functx:time" as="xs:time"
              xmlns:functx="http://www.functx.com">
  <xsl:param name="hour" as="xs:anyAtomicType"/>
  <xsl:param name="minute" as="xs:anyAtomicType"/>
  <xsl:param name="second" as="xs:anyAtomicType"/>

  <xsl:sequence select="
   xs:time(
     concat(
       functx:pad-integer-to-length(xs:integer($hour),2),':',
       functx:pad-integer-to-length(xs:integer($minute),2),':',
       functx:pad-integer-to-length(xs:integer($second),2)))
 "/>

</xsl:function>

Examples

XPath ExampleResults
functx:time(20,6,12)
20:06:12
functx:time('20','6','12')
20:06:12

Depends On

functx:pad-integer-to-lengthPads an integer to a desired length by adding leading zeros

See Also

functx:dateConstruct a date from a year, month and day

History

Published OnLast UpdatedContributor(s)
2006-08-222007-02-26Priscilla Walmsley, Datypic, pwalmsley@datypic.com, http://www.datypic.com
Datypic XSLT Services

Recommended Reading:

XQuery