def _quote_tag_if_needed(tag: str) -> str:
    """Quotes tags just like timewarrior would quote them.

    Args:
        tag: The tag that should be quoted.

    Returns:
        The quoted tag.
    """
    if tag[0] == '"' or tag[0] == "'":
        return tag

    special_chars = [" ", '"', "+", "-", "/", "(", ")", "<", "^", "!", "=", "~", "_", "%"]

    if any(char in tag for char in special_chars):
        return f'"{tag}"'

    return tag