xf:get-hours-from-time

Extracts the hours from $time-var.

If the value of $time-var is the empty sequence, the empty sequence is returned. The empty sequence is a sequence containing zero items (), which is similar to null in SQL.

Signatures

xf:get-hours-from-time(xs:time? $time-var) —> xs:integer?

Arguments

Data Type
Argument
Description

xs:time?

$time-var

Contains a representation of time.

Returns

Returns the hours as an integer from $time-var.

Examples

Simple

The following is a simple example using the get-hours-from-time function:

<hours>{xf:get-hours-from-time("22:21:01")}</hours> 

The preceding query generates the following result:

<hours>22</hours> 

Timezone

The following example uses the get-hours-from-time function with a timezone:

<hours>{xf:get-hours-from-time("14:21:01-05:00")}</hours> 

The preceding query generates the following result:

<hours>19</hours> 

In the preceding query, the -05:00 string specifies the time is specified in the Eastern Standard timezone which is 5 hours behind Coordinated Universal Time (UTC). The hours are reported in Coordinated Universal Time (UTC), so 5 hours are added to 14 hours of the Eastern Standard timezone, resulting in 19 hours in Coordinated Universal Time (UTC).

Related Topics

W3C get-hours-from-time function description.

W3C time data type description.