def validate_time_str(time_str):
    """Return True if time string is valid."""
    ### try splitting the time string into substrings
    ### representing the hour, minutes and seconds
    try:
        hour, minutes, seconds = time_str.split(":")

    ### if the splitting fails, it means we don't have
    ### a valid time string, so we return False
    except ValueError:
        return False

    ### otherwise, all substring retrieved must be entirely
    ### numeric, otherwise the time string isn't valid

    if not all(str.isnumeric(string) for string in (hour, minutes, seconds)):
        return False

    ### and each substring must represent an integer
    ### within a specific range according to the substring
    ### meaning, otherwise the time string isn't valid

    if (
        int(hour) in range(24)
        and int(minutes) in range(60)
        and int(seconds) in range(60)
    ):
        return True

    else:
        return False
Return True if time string is valid.
nodezator/syntaxman/syntaxes/userlog.py