xs:gYear

Converts $string-var (a string in the gYear format) to the gYear data type.

If the value of $string-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.

If the value of $string-var is not valid to the gYear format, the following error is reported:

Could not cast "invalid_gYear_string" to type [gYear@htttp://www.w3.org/2001/XMLSchema] is displayed.

Where invalid_gYear_string is the string not valid to the time format, for example: "20-2003".

Signatures

xs:gYear(xs:string $string-var) —> xs:gYear

Arguments

Data Type
Argument
Description

xs:string

$string-var

Represents a string with the year specified with one of the following formats:

  • YYYY
  • YYYYZ
  • YYYY+hh:mm
  • YYYY-hh:mm



YYYY

Year.



+

Positive time zone offset. This option is optional. If a plus or minus is not specified, + is assumed.



-

Negative time zone offset. (Optional)



hh

Number of hours that the time zone differs from UTC.



mm

Number of minutes that the time zone differs from UTC.



Z

Indicates that the time corresponds to the UTC time zone.

Returns

Returns the specified year in the gYear data type.

Examples

Simple

Invoking gYear("2003") returns a gYear value corresponding to the year 2003, as shown in the following example query:

<result>{xs:gYear("2003")}</result> 

The preceding query, generates the following XML result:

<result>2003</result> 

UTC Time Zone

Invoking gYear("2003Z") returns a gYear value corresponding to the year 2003 in the UTC time zone, as shown in the following example query:

<result>{xs:gYear("2003Z")}</result> 

The preceding query, generates the following XML result:

<result>2003Z</result> 

Related Topics

W3C gYear data type description