MatchesXsDateTime🔗

Type: Pattern verification
Check that text conforms to the pattern of an xs:dateTime.
text🔗
Text to be checked
Return🔗
True if the text conforms to the pattern

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]))'
)
hourFrag = (
    f'(([01]{digit})|(2[0-3]))'
)
minuteFrag = (
    f'[0-5]{digit}'
)
secondFrag = (
    f'([0-5]{digit})(\\.{digit}+)?'
)
endOfDayFrag = (
    '24:00:00(\\.0+)?'
)
timezoneFrag = (
    f'(Z|(\\+|-)((0{digit}|1[0-3]):{minuteFrag}|14:00))'
)
dateTimeLexicalRep = (
    f'{yearFrag}-{monthFrag}-{dayFrag}T(({hourFrag}:{minuteFrag}:{secondFrag})|{endOfDayFrag}){timezoneFrag}?'
)
pattern = (
    f'^{dateTimeLexicalRep}$'
)
return match(
    pattern,
    text
) is not None