import time


def get_nth_day(day_name, n, year, month):
    """Get Nth occurence of day named <blah> in some month.  If n = -1, return the last one.

    Args:
        day_name (str): name of day, full and capitalized, e.g. "Thursday"
        n (int): Nth occurrence of day_name (1 = first, -1 = last)
        year (int): 4-digit year
        month (int): integer month (1 = Jan, 2 = Feb, etc.)
    Returns:
        jday (int): Julian date
    """
    days_matched = []
    for d in range(1, 32):
        try:
            dt = time.strptime("{} {} {}".format(year, month, d), "%Y %m %d")
            dname = time.strftime("%A", dt)
            if dname == day_name:
                j = int(time.strftime("%j", dt))
                days_matched.append(j)
        except ValueError:
            pass
    if n == -1:
        return days_matched[-1]
    else:
        return days_matched[n-1]