MatchesXsDateTimeStampUtc🔗
Check that
text conforms to the pattern of an xs:dateTimeStamp.
The time zone must be fixed to UTC. We verify only that the text matches
a pre-defined pattern. We
do not
verify that the day of month is
correct nor do we check for leap seconds.
Code
digit = "[0-9]"
year_frag = f"-?(([1-9]{digit}{digit}{digit}+)|(0{digit}{digit}{digit}))"
month_frag = f"((0[1-9])|(1[0-2]))"
day_frag = f"((0[1-9])|([12]{digit})|(3[01]))"
hour_frag = f"(([01]{digit})|(2[0-3]))"
minute_frag = f"[0-5]{digit}"
second_frag = f"([0-5]{digit})(\\.{digit}+)?"
end_of_day_frag = "24:00:00(\\.0+)?"
timezone_frag = "Z"
date_time_stamp_lexical_rep = (
f"{year_frag}-{month_frag}-{day_frag}"
f"T"
f"(({hour_frag}:{minute_frag}:{second_frag})|{end_of_day_frag})"
f"{timezone_frag}"
)
pattern = f"^{date_time_stamp_lexical_rep}$"
return match(pattern, text) is not None