MatchesXsDayTimeDuration🔗
Check that
text conforms to the pattern of an xs:dayTimeDuration.
Code
day_time_duration_rep = (
r"-?P(("
r"([0-9]+D)"
r"(T(([0-9]+H)([0-9]+M)?([0-9]+(\.[0-9]+)?S)?"
r"|([0-9]+M)([0-9]+(\.[0-9]+)?S)?"
r"|([0-9]+(\.[0-9]+)?S)"
r")"
r")?"
r")"
r"|(T(([0-9]+H)([0-9]+M)?([0-9]+(\.[0-9]+)?S)?"
r"|([0-9]+M)([0-9]+(\.[0-9]+)?S)?"
r"|([0-9]+(\.[0-9]+)?S)"
r")"
r")"
r")"
)
# fmt: on
pattern = f"^{day_time_duration_rep}$"
return match(pattern, text) is not None