MatchesXsDate🔗
Check that
text
conforms to the pattern of an xs:date
.
Code
digit = '[0-9]'
yearFrag = (
f'-?(([1-9]{digit}{digit}{digit}+)|(0{digit}{digit}{digit}))'
)
monthFrag = (
'((0[1-9])|(1[0-2]))'
)
dayFrag = (
f'((0[1-9])|([12]{digit})|(3[01]))'
)
minuteFrag = (
f'[0-5]{digit}'
)
timezoneFrag = (
f'(Z|(\\+|-)((0{digit}|1[0-3]):{minuteFrag}|14:00))'
)
dateLexicalRep = (
f'{yearFrag}-{monthFrag}-{dayFrag}{timezoneFrag}?'
)
pattern = (
f'^{dateLexicalRep}$'
)
return match(
pattern,
text
) is not None