http://www.zorba-xquery.com/modules/datetime ZC

Module Description
Before using any of the functions below please remember to import the module namespace:
import module namespace datetime = "http://www.zorba-xquery.com/modules/datetime";

This module provides functions to retrieve the current dateTime and to parse dates and times. In contrast to the current-dateTime functions specified in XQuery Functions and Operators, the functions in this module are nondeterministic, that is, they do not return the current dateTime from the dynamic context, but return the actual value. Dates and times are parsed according to the format given by strptime. However, date and time values must be "complete." For a date, the year and either month and day or day of the year must have been parsed. For a time, the hour must have been parsed. (If either the minute, second, or timezone has not been parsed, they default to 0.) For a dateTime, the parsing requirements of both date and time must be met. When a locale is given, it must be of the form {lang}[{sep}{country}[{encoding}]] where {lang} is an ISO 639-1 2-letter or 639-2 3-letter language code, {sep} is either '-' or '_', {country} is an ISO 3166-1 2-letter country code, and {encoding} is any string that begins with a '.'. The {sep}, {country}, and {encoding} are optional; {encoding} is always ignored. Examples include: de, en-US, fr_CA, ru_RU.UTF-8.

Author:

Matthias Brantner

Author:

Paul J. Lucas

XQuery version and encoding for this module:

xquery version "3.0" encoding "utf-8";

Zorba version for this module:

The latest version of this module is 2.0. For more information about module versioning in Zorba please check out this resource.

Module Resources
Related Documentation

For more details please also see:

Namespaces
an http://www.zorba-xquery.com/annotations
datetime http://www.zorba-xquery.com/modules/datetime
ver http://www.zorba-xquery.com/options/versioning
zerr http://www.zorba-xquery.com/errors
Function Summary
Nondeterministic External current-date ( ) as xs:date
Gets the current date value in Universal time.
Nondeterministic External current-dateTime ( ) as xs:dateTimeStamp
Gets the current dateTime value in Universal time.
Nondeterministic External current-time ( ) as xs:time
Return the current time value in Universal time.
External millis-to-dateTime ( $millis as xs:long ) as xs:dateTime
Converts the given number of milliseconds since epoch into its corresponding xs:dateTime.
External parse-date ( $input as xs:string, $format as xs:string ) as xs:date
Parses a date from a string in the current locale.
External parse-date ( $input as xs:string, $format as xs:string, $locale as xs:string ) as xs:date
Parses a date from a string in the given locale.
External parse-dateTime ( $input as xs:string, $format as xs:string ) as xs:dateTime
Parses a dateTime from a string in the current locale.
External parse-dateTime ( $input as xs:string, $format as xs:string, $locale as xs:string ) as xs:dateTime
Parses a dateTime from a string in the given locale.
External parse-time ( $input as xs:string, $format as xs:string ) as xs:time
Parses a time from a string in the current locale.
External parse-time ( $input as xs:string, $format as xs:string, $locale as xs:string ) as xs:time
Parses a time from a string in the given locale.
Nondeterministic External timestamp ( ) as xs:long
Gets the the number of milliseconds since epoch.
Nondeterministic External utc-offset ( ) as xs:long
Gets the offset of the current timezone from Universal time.
Functions
Nondeterministic External current-date back to 'Function Summary'
declare function datetime:current-date (

) as xs:date

Gets the current date value in Universal time. Note that this function is not stable: it returns the value of the date when the function is invoked.

Returns:

Nondeterministic External current-dateTime back to 'Function Summary'
declare function datetime:current-dateTime (

) as xs:dateTimeStamp

Gets the current dateTime value in Universal time. Note that this function is not stable: it returns the value of the date and time when the function is invoked.

Returns:

Nondeterministic External current-time back to 'Function Summary'
declare function datetime:current-time (

) as xs:time

Return the current time value in Universal time. Note that this function is not stable: it returns the value of the time when the function is invoked.

Returns:

External millis-to-dateTime back to 'Function Summary'
declare function datetime:millis-to-dateTime (
            $millis as xs:long
) as xs:dateTime

Converts the given number of milliseconds since epoch into its corresponding xs:dateTime.

Parameters:
Returns:
Examples:

External parse-date back to 'Function Summary'
declare function datetime:parse-date (
            $input as xs:string,
            $format as xs:string
) as xs:date

Parses a date from a string in the current locale.

Parameters:
Returns:
Errors:
Examples:

External parse-date back to 'Function Summary'
declare function datetime:parse-date (
            $input as xs:string,
            $format as xs:string,
            $locale as xs:string
) as xs:date

Parses a date from a string in the given locale.

Parameters:
Returns:
Errors:
Examples:

External parse-dateTime back to 'Function Summary'
declare function datetime:parse-dateTime (
            $input as xs:string,
            $format as xs:string
) as xs:dateTime

Parses a dateTime from a string in the current locale.

Parameters:
Returns:
Errors:
Examples:

External parse-dateTime back to 'Function Summary'
declare function datetime:parse-dateTime (
            $input as xs:string,
            $format as xs:string,
            $locale as xs:string
) as xs:dateTime

Parses a dateTime from a string in the given locale.

Parameters:
Returns:
Errors:
Examples:

External parse-time back to 'Function Summary'
declare function datetime:parse-time (
            $input as xs:string,
            $format as xs:string
) as xs:time

Parses a time from a string in the current locale.

Parameters:
Returns:
Errors:
Examples:

External parse-time back to 'Function Summary'
declare function datetime:parse-time (
            $input as xs:string,
            $format as xs:string,
            $locale as xs:string
) as xs:time

Parses a time from a string in the given locale.

Parameters:
Returns:
Errors:
Examples:

Nondeterministic External timestamp back to 'Function Summary'
declare function datetime:timestamp (

) as xs:long

Gets the the number of milliseconds since epoch.

Returns:

Nondeterministic External utc-offset back to 'Function Summary'
declare function datetime:utc-offset (

) as xs:long

Gets the offset of the current timezone from Universal time.

Returns: