home contribute faq download

FunctX XQuery Functions

functx:time

Construct a time from an hour, minute and second

Google
Webdatypic.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

XQuery Function Declaration

See XSLT definition.
declare namespace functx = "http://www.functx.com";
declare function functx:time
  ( $hour as xs:anyAtomicType ,
    $minute as xs:anyAtomicType ,
    $second as xs:anyAtomicType )  as xs:time {

   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)))
 } ;

Examples

XQuery 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, https://www.datypic.com
Datypic XQuery Services

Recommended Reading:

XQuery