MatchesTimeLiteral🔗
Check that
text is a valid time literal of the query language.
A time literal is given as
HH:MM, HH:MM:SS, optionally with
fractional seconds and an optional time zone,
e.g.
, 12:00:00+01:00.
Code
digit = "[0-9]"
time = (
f"(([01]{digit}|2[0-3]):[0-5]{digit}(:[0-5]{digit})?(\\.{digit}+)?"
f"|24:00(:00)?(\\.0+)?)"
)
timezone = f"(Z|[+-]((0{digit}|1[0-3]):[0-5]{digit}|14:00))"
pattern = f"^{time}{timezone}?$"
return match(pattern, text) is not None