home contribute faq download

FunctX XQuery Functions

functx:time

Construct a time from an hour, minute and second

Google
Webxqueryfunctions.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.
XQuery Syntax for January 2007 (1.0):
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)))
 } ;
XQuery Syntax for July 2004 - November 2005 (CR):
declare namespace functx = "http://www.functx.com"; 
declare function functx:time 
  ( $hour as xdt:anyAtomicType ,
    $minute as xdt:anyAtomicType ,
    $second as xdt: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)))
 } ;
XQuery Syntax for May 2003:
declare namespace functx = "http://www.functx.com" 
define function time 
  ( $hour as xdt:anyAtomicType ,
    $minute as xdt:anyAtomicType ,
    $second as xdt:anyAtomicType )  as xs:time {
       
   xs:time(
     fn: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, http://www.datypic.com
Need XQuery Help?
D A T Y P I C
Training | Consulting | Development

XQuery by Priscilla WalmsleyGet the book!
XQuery by Priscilla Walmsley