is_holiday({now}, {holidays="/etc/acct/holidays"}

def is_holiday(now=None, holidays="/etc/acct/holidays"):
    """is_holiday({now}, {holidays="/etc/acct/holidays"}"""
    now = _Time(now)
    # Now, parse holiday file.
    if not os.path.exists(holidays):
        raise Exception("There is no holidays file: %s" % holidays)

    f = open(holidays, "r")
    # First, read all leading comments.
    line = f.readline()
    while line[0] == '*': line = f.readline()

    # We just got the year line.
    (year, primestart, primeend) = str.split(line)
    # If not the right year, we have no idea for certain.  Skip.
    if not year == now.year: return 0

    # Now the dates.  Check each against now.
    while line != '':
        # Of course, ignore comments.
        if line[0] == '*':
            line = f.readline()
            continue

        try:
            # Format: "1/1	New Years Day"
            (month, day) = str.split(str.split(line)[0], "/")
            # The _Time class has leading-zero padded day numbers.
            if len(day) == 1: day = '0' + day
            # Get month number from index map (compensate for zero indexing).
            month = MONTH_MAP[int(month) - 1]

            # Check the date.
            #print month, now.month, day, now.day
            if month == now.month and day == now.day:
                return 1

            line = f.readline()
        except:
            # Skip malformed lines.
            line = f.readline()
            continue

    # If no match found, we must not be in a holiday.
    return 0