if month > 12 or < -12 or == 0, raise exception
 if the month < 0, then subtract that number from 12 and decrement the year
 otherwise, just set the month and year

 @param [Fixnum] new_year
 @param [Fixnum] new_month
498066
def setup_year_and_month(new_year, new_month)
      if new_month > 12 || new_month < -12 || new_month == 0
        raise Exception "Month out of range.  Allowable values: 1..12 and -12..-1."
      elsif new_month < 0
        @year = new_year - 1
        @month = 13 + new_month
      else
        @year = new_year
        @month = new_month
      end
    end
1314254
def month=(value)
      value = 0 if value.nil?

      if value.is_a?(String) 
        if value.length == 0
          value = 0
        elsif value =~ /\A\d{1,2}\z/ 
          value = value.to_i
        else
          raise MonthError, "Month must be a valid one or two digit string or integer between 0 and 12"
        end
      end

      if (value >= 0 && value <= 12)
        @bits = self.class.set_month(@bits, value)
        @bits = self.class.set_day(@bits, 0) if value == 0
      else
        raise MonthError, "Month must an be integer between 0 and 12"
      end
    end
878972
def sub_days(number)
      o = dup
      while number > 0
        if (o.day - 1) >= number
          o.date = ZDate.format_date(o.year_str, o.month_str, o.day - number)
          number = 0
        else
          number -= o.day
          o.decrement_month!
        end
      end
      o
    end
497934
private int parseMonth(String month) {
    for (int i = 0; i < months.length; i++)
      if (months[i].startsWith(month))
        return i;
    return -1;
  }
328082
public void setMonths(String[] newMonths, int context, int width) {
        switch (context) {
           case FORMAT :
              switch(width) {
                 case WIDE :
                    months = duplicate(newMonths);
                    break;
                 case ABBREVIATED :
                    shortMonths = duplicate(newMonths);
                    break;
                 case NARROW :
                    narrowMonths = duplicate(newMonths);
                    break;
                 default : // HANDLE SHORT, etc.
                    break;
              }
              break;
           case STANDALONE :
              switch(width) {
                 case WIDE :
                    standaloneMonths = duplicate(newMonths);
                    break;
                 case ABBREVIATED :
                    standaloneShortMonths = duplicate(newMonths);
                    break;
                 case NARROW :
                    standaloneNarrowMonths = duplicate(newMonths);
                    break;
                 default : // HANDLE SHORT, etc.
                    break;
              }
              break;
        }
    }
987116
def decrement(index=-1)
      value = @components[index]
      raise TypeError.new "'#{value}' is not an integer" unless value.is_a? Integer
      raise RangeError.new "'#{value}' is zero or less" unless value > 0

      copy = Array.new @components
      copy[index] = value - 1
      self.class.new copy
    end
702199
protected void setError(int newPosition, String error,
      boolean currentExisting) {
    if (!currentExisting) {
      newFullValueList[newPosition] = operations.createVector1(0);
    }
    newErrorNumber[newPosition]++;
    if (newErrorList[newPosition].containsKey(error)) {
      newErrorList[newPosition].put(error,
          newErrorList[newPosition].get(error) + 1);
    } else {
      newErrorList[newPosition].put(error, 1);
    }
  }
783952
protected void setError(int newPosition, String error,
      boolean currentExisting) {
    if (!currentExisting) {
      newBasicValueSumList[newPosition] = operations.getZero1();
      newBasicValueNList[newPosition] = 0;
    }
    newErrorNumber[newPosition]++;
    if (newErrorList[newPosition].containsKey(error)) {
      newErrorList[newPosition].put(error,
          newErrorList[newPosition].get(error) + 1);
    } else {
      newErrorList[newPosition].put(error, 1);
    }
  }
596235
def redeploy_days_before_certificate_expires=(new_val)
      return nil if redeploy_days_before_certificate_expires == new_val
      raise JSS::InvalidDataError, 'New value must be an integer >= 0' unless new_val.is_a?(Integer) && new_val >= 0
      @redeploy_days_before_certificate_expires = new_val
      @need_to_update = true
    end
347209
protected void setError(int newPosition, String error,
      boolean currentExisting) {
    if (!currentExisting) {
      newAdvancedValueSumList[newPosition] = operations.getZero1();
      newAdvancedValueSumOfLogsList[newPosition] = operations.getZero2();
      newAdvancedValueSumOfSquaresList[newPosition] = operations.getZero1();
      newAdvancedValueMinList[newPosition] = operations.getZero1();
      newAdvancedValueMaxList[newPosition] = operations.getZero1();
      newAdvancedValueNList[newPosition] = 0;
    }
    newErrorNumber[newPosition]++;
    if (newErrorList[newPosition].containsKey(error)) {
      newErrorList[newPosition].put(error,
          newErrorList[newPosition].get(error) + 1);
    } else {
      newErrorList[newPosition].put(error, 1);
    }
  }
392439
public static Date dateReservedMonth(int year, int month, boolean is000) {
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.YEAR, year);
        if (month <= 1) {
            calendar.set(Calendar.MONTH, Calendar.JANUARY);
        } else if (month >= 12) {
            calendar.set(Calendar.MONTH, Calendar.DECEMBER);
        } else {
            calendar.set(Calendar.MONTH, month - 1);
        }
        return is000 ? dateReservedMonth000(calendar) : dateReservedMonth999(calendar);
    }
1322041
function(year, month, date) {

    // change value from to zero-based
    date--;
    year--;

    // combine year and month to get the actual year and month
    // this allows user to set a negative month number
    var months = year2months(year) + month;
    year = months2year(months);
    month = months - year2months(year);
    months -= month;

    var days = getNewYearInDays(months);

    var leap = isLeap(year);
    var nextYear = getNextYearInDays(months, leap);
    var mode = getYearMode(days, nextYear, leap);

    days += Math.ceil(month * 29.5);
    if(month > 1 && mode == 1 || month > 2) days += mode;
    if(month > 5) days += leap;

    days += date;

    return days - DISTANCE;
  }
686137
private void addMonth(int i) {
        Calendar cal = Calendar.getInstance();
        cal.set(getDisplayYear(), getDisplayMonth() - 1, 1);
        int month = cal.get(Calendar.MONTH) + 1;
        if (i > 0 && month == 12) {
            addYear(1);
        }

        if (i < 0 && month == 1) {
            addYear(-1);
        }
        cal.add(Calendar.MONTH, i);

        monthTextField.setText(String.valueOf(cal.get(Calendar.MONTH) + 1));

    }
772432
def _add_months(self, date, months):
        
        year = date.year + (date.month + months - 1) // 12
        month = (date.month + months - 1) % 12 + 1
        return datetime.date(year=year, month=month, day=1)
526173
def >> n
      y, m = (year * 12 + (mon - 1) + n).divmod(12)
      m, = (m + 1) .divmod(1)
      d = mday
      until jd2 = _valid_civil?(y, m, d)
        d -= 1
        raise ArgumentError, 'invalid date' unless d > 0
      end
      self + (jd2 - jd)
    end
146188
function adjustDayOfMonth(self) {
        var fields = self.fields;
        var year = fields[YEAR];
        var month = fields[MONTH];
        var monthLen = getMonthLength(year, month);
        var dayOfMonth = fields[DAY_OF_MONTH];
        if (dayOfMonth > monthLen) {
            self.set(DAY_OF_MONTH, monthLen);
        }
    }
525069
function check_bymonth(rules, dt) {
    if(!rules || !rules.length) return true;
    return rules.indexOf(m(dt)) !== -1;
}