docs: def valid_time(x: str) -> bool:
      """
      Return ``True`` if ``x`` is a valid H:MM:SS or HH:MM:SS time;
      otherwise return ``False``.
      """
      if isinstance(x, str) and (
          re.match(TIME_PATTERN1, x) or re.match(TIME_PATTERN2, x)
      ):
          return True
      else:
          return False