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".
xs:gYear(xs:string $string-var) —> xs:gYear
Represents a string with the year specified with one of the following formats: |
|||
Positive time zone offset. This option is optional. If a plus or minus is not specified, + is assumed. |
|||
Returns the specified year in the gYear data type.
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>
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>
W3C gYear data type description