问题描述
我试图找到一个更好的可读解决方案来匹配格式中的 DateTime 字符串:
2020 年 8 月 10 日星期一 18:53:56
在 PHP date format 中:
D M d H:i:s Y
我目前的解决方案是:
<xs:simpleType name="dateTimeType">
<xs:restriction base="xs:string">
<xs:pattern value="((Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (([0-2][0-9])|(3[0-1])) (([0-1][0-9])|(2[0-3])):[0-5][0-9]:[0-5][0-9] [0-9]{4})?" />
</xs:restriction>
</xs:simpleType>
我正在考虑这样的事情:
<xs:simpleType name="weekdayType">
<xs:restriction base="xs:string">
<xs:pattern value="Mon|Tue|Wed|Thu|Fri|Sat|Sun" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="monthType">
<xs:restriction base="xs:string">
<xs:pattern value="Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="monthdayType">
<xs:restriction base="xs:string">
<xs:pattern value="([0-2][0-9])|(3[0-1])" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="timeType">
<xs:restriction base="xs:string">
<xs:pattern value="(([0-1][0-9])|(2[0-3])):[0-5][0-9]:[0-5][0-9]" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="yearType">
<xs:restriction base="xs:string">
<xs:pattern value="[0-9]{4}" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="dateTimeType">
<xs:restriction base="xs:string">
<xs:pattern value="(weekdayType monthType monthdayType timeType yearType)?" />
</xs:restriction>
</xs:simpleType>
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)