<xs:simpleType name="dateTimeWithTimezone">
<xs:restriction base="xs:dateTime">
<xs:pattern value=".+T.+(Z|[+-].+)"/>
</xs:restriction>
</xs:simpleType>
Still simpler, applications that want to make sure that none of their
datetimes specify a time zone may just check that the time part
doesn't contain the characters
"+",
"-", or
"Z":
<xs:simpleType name="dateTimeWithoutTimezone">
<xs:restriction base="xs:dateTime">
<xs:pattern value=".+T[^Z+-]+"/>
</xs:restriction>
</xs:simpleType>
In these two datatypes, we used the separator
"T". This is convenient, since no
occurrences of the signs can occur after this delimiter except in the
time zone definition. This delimiter would be missing if we wanted to
constrain dates instead of datetimes, but, in this case, we can
detect the time zones on their ":"
instead:
<xs:simpleType name="dateWithTimezone">
<xs:restriction base="xs:date">
<xs:pattern value=".+[:Z].*"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="dateWithoutTimezone">
<xs:restriction base="xs:date">
<xs:pattern value="[^:Z]*"/>
</xs:restriction>
</xs:simpleType>
Applications may also simply impose a set of time zones to use:
<xs:simpleType name="dateTimeInMyTimezones">
<xs:restriction base="xs:dateTime">
<xs:pattern value=".+\+02:00"/>
<xs:pattern value=".+\+01:00"/>
<xs:pattern value=".+\+00:00"/>
<xs:pattern value=".+Z"/>
<xs:pattern value=".+-04:00"/>
</xs:restriction>
</xs:simpleType>