- All Modules
- All Functions
-
www.w3.org
- 2005
- XDM
- store
- introspection
- reflection
- external
-
xqdoc
-
xqdoc
(E)
-
project_xqdoc
- xqdoc2xhtml
-
xqdoc
(E)
- data processing
- expath.org
- www.functx.com
- Zorba
- debugger
- error
- jsoniq.org
- www.zorba-xquery.com
http://www.zorba-xquery.com/modules/datetime
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.
Matthias Brantner
Paul J. Lucas
xquery version "3.0" encoding "utf-8";
The latest version of this module is 2.0. For more information about module versioning in Zorba please check out this resource.
- the XQuery module can be found here.
For more details please also see:
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 |
![]() ![]() |
current-date
(
) as xs:date Gets the current date value in Universal time. |
![]() ![]() |
current-dateTime
(
) as xs:dateTimeStamp Gets the current dateTime value in Universal time. |
![]() ![]() |
current-time
(
) as xs:time Return the current time value in Universal time. |
![]() |
millis-to-dateTime
(
$millis as xs:long
) as xs:dateTime Converts the given number of milliseconds since epoch into its corresponding xs:dateTime. |
![]() |
parse-date
(
$input as xs:string,
$format as xs:string
) as xs:date Parses a date from a string in the current locale. |
![]() |
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. |
![]() |
parse-dateTime
(
$input as xs:string,
$format as xs:string
) as xs:dateTime Parses a dateTime from a string in the current locale. |
![]() |
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. |
![]() |
parse-time
(
$input as xs:string,
$format as xs:string
) as xs:time Parses a time from a string in the current locale. |
![]() |
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. |
![]() ![]() |
timestamp
(
) as xs:long Gets the the number of milliseconds since epoch. |
![]() ![]() |
utc-offset
(
) as xs:long Gets the offset of the current timezone from Universal time. |
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.
- the non-stable date value
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.
- the non-stable datetime value
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.
- the non-stable time value
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.
- $millis The number of milliseconds since epoch.
- Returns an xs:dateTime.
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.
- $input The string to parse.
- $format The format string containing zero or more conversion specifications and ordinary characters. All ordinary characters are matched exactly with the buffer; all whitespace characters match any amount of whitespace in the buffer.
- Returns an xs:date.
- zerr:ZDTP0001 if $format contains an invalid conversion specification.
- zerr:ZDTP0002 if $input is insufficient for $format.
- zerr:ZDTP0003 if $input contains an invalid value for a conversion specification.
- zerr:ZDTP0004 if there is a literal characer mismatch between $input and $format.
- zerr:ZDTP0005 if the date is incomplete.
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.
- $input The string to parse.
- $format The format string containing zero or more conversion specifications and ordinary characters. All ordinary characters are matched exactly with the buffer; all whitespace characters match any amount of whitespace in the buffer.
- $locale The locale to use.
- Returns an xs:date.
- zerr:ZDTP0001 if $format contains an invalid conversion specification.
- zerr:ZDTP0002 if $input is insufficient for $format.
- zerr:ZDTP0003 if $input contains an invalid value for a conversion specification.
- zerr:ZDTP0004 if there is a literal characer mismatch between $input and $format.
- zerr:ZDTP0005 if the date is incomplete.
- zerr:ZXQP0011 if $locale is in an invalid format.
- zerr:ZXQP0012 if $locale is unknown.
- zerr:ZOSE0007 if $locale is unsupported by the operating system.
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.
- $input The string to parse.
- $format The format string containing zero or more conversion specifications and ordinary characters. All ordinary characters are matched exactly with the buffer; all whitespace characters match any amount of whitespace in the buffer.
- Returns an xs:dateTime.
- zerr:ZDTP0001 if $format contains an invalid conversion specification.
- zerr:ZDTP0002 if $input is insufficient for $format.
- zerr:ZDTP0003 if $input contains an invalid value for a conversion specification.
- zerr:ZDTP0004 if there is a literal characer mismatch between $input and $format.
- zerr:ZDTP0005 if either the date or time is incomplete.
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.
- $input The string to parse.
- $format The format string containing zero or more conversion specifications and ordinary characters. All ordinary characters are matched exactly with the buffer; all whitespace characters match any amount of whitespace in the buffer.
- $locale The locale to use.
- Returns an xs:dateTime.
- zerr:ZDTP0001 if $format contains an invalid conversion specification.
- zerr:ZDTP0002 if $input is insufficient for $format.
- zerr:ZDTP0003 if $input contains an invalid value for a conversion specification.
- zerr:ZDTP0004 if there is a literal characer mismatch between $input and $format.
- zerr:ZDTP0005 if either the date or time is incomplete.
- zerr:ZXQP0011 if $locale is in an invalid format.
- zerr:ZXQP0012 if $locale is unknown.
- zerr:ZOSE0007 if $locale is unsupported by the operating system.
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.
- $input The string to parse.
- $format The format string containing zero or more conversion specifications and ordinary characters. All ordinary characters are matched exactly with the buffer; all whitespace characters match any amount of whitespace in the buffer.
- Returns an xs:time.
- zerr:ZDTP0001 if $format contains an invalid conversion specification.
- zerr:ZDTP0002 if $input is insufficient for $format.
- zerr:ZDTP0003 if $input contains an invalid value for a conversion specification.
- zerr:ZDTP0004 if there is a literal characer mismatch between $input and $format.
- zerr:ZDTP0005 if the hour has not been parsed.
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.
- $input The string to parse.
- $format The format string containing zero or more conversion specifications and ordinary characters. All ordinary characters are matched exactly with the buffer; all whitespace characters match any amount of whitespace in the buffer.
- $locale The locale to use.
- Returns an xs:time.
- zerr:ZDTP0001 if $format contains an invalid conversion specification.
- zerr:ZDTP0002 if $input is insufficient for $format.
- zerr:ZDTP0003 if $input contains an invalid value for a conversion specification.
- zerr:ZDTP0004 if there is a literal characer mismatch between $input and $format.
- zerr:ZDTP0005 if the hour has not been parsed.
- zerr:ZXQP0011 if $locale is in an invalid format.
- zerr:ZXQP0012 if $locale is unknown.
- zerr:ZOSE0007 if $locale is unsupported by the operating system.
declare function datetime:timestamp ( ) as xs:long
Gets the the number of milliseconds since epoch.
- the said number of milliseconds.
declare function datetime:utc-offset ( ) as xs:long
Gets the offset of the current timezone from Universal time.
- the offset in seconds with positive values being east of the prime meridian.