accepts 0 (December in the previous year) to 12.
330635
private int getMonthLength(int year, int month) {
        int days = DAYS_IN_MONTH[month];
        if (month == FEBRUARY && isLeapYear(year)) {
            days++;
        }
        return days;
    }
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;
  }
581996
function fuzzydate(s) {
	var o = new Date(s), n = new Date(NaN);
	var y = o.getYear(), m = o.getMonth(), d = o.getDate();
	if(isNaN(d)) return n;
	if(y < 0 || y > 8099) return n;
	if((m > 0 || d > 1) && y != 101) return o;
	if(s.toLowerCase().match(/jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec/)) return o;
	if(!s.match(/[a-zA-Z]/)) return o;
	return n;
}
589793
def coarse_precision(date_year, interval)

      date_year = date_year.to_i
      interval = interval.to_i

      year_diff = date_year - ::Date.today.year
      return "Within the last #{number_with_delimiter(interval)} years" if (-(interval - 1)..0).include? year_diff
      return "Within the next #{number_with_delimiter(interval)} years" if (1..(interval - 1)).include? year_diff

      rounded = (year_diff.to_f / interval.to_f).round * interval
      return "in #{number_with_delimiter(rounded.abs)} years" if rounded > 0
      return "#{number_with_delimiter(rounded.abs)} years ago" if rounded < 0

      nil
    end
929001
def last_year(date_):
    '''
    
    '''
    day = 28 if date_.day == 29 and date_.month == 2 else date_.day
    return datetime.date(date_.year-1, date_.month, day)
1330203
def _yyyymmdd_to_year_fraction(date):
    """"""
    date = str(date)
    if '.' in date:
        date, residual = str(date).split('.')
        residual = float('0.' + residual)
    else:
        residual = 0.0

    date = _datetime.datetime.strptime(date, '%Y%m%d')
    date += _datetime.timedelta(days=residual)

    year = date.year
    year_start = _datetime.datetime(year=year, month=1, day=1)
    next_year_start = _datetime.datetime(year=year + 1, month=1, day=1)
    year_duration = next_year_start - year_start

    year_elapsed = date - year_start
    fraction = year_elapsed / year_duration

    return year + fraction
250691
public static boolean isLeapYear(int y) {
		boolean result = false;

		if (((y % 4) == 0) && // must be divisible by 4...
				((y < 1582) || // and either before reform year...
						((y % 100) != 0) || // or not a century...
						((y % 400) == 0))) { // or a multiple of 400...
			result = true; // for leap year.
		}
		return result;
	}
162539
def _timestamp_zero_start_handler(c, ctx):
    
    val = ctx.value
    ctx.set_ion_type(IonType.TIMESTAMP)
    if val[0] == _MINUS:
        _illegal_character(c, ctx, 'Negative year not allowed.')
    val.append(c)
    c, self = yield
    trans = ctx.immediate_transition(self)
    while True:
        if c in _TIMESTAMP_YEAR_DELIMITERS:
            trans = ctx.immediate_transition(_timestamp_handler(c, ctx))
        elif c in _DIGITS:
            val.append(c)
        else:
            _illegal_character(c, ctx)
        c, _ = yield trans
722357
function(years) {
			years = years.split('.');
			if (years.length < 3) {
				throw 'Invalid Mayan year';
			}
			var year = 0;
			for (var i = 0; i < years.length; i++) {
				var y = parseInt(years[i], 10);
				if (Math.abs(y) > 19 || (i > 0 && y < 0)) {
					throw 'Invalid Mayan year';
				}
				year = year * 20 + y;
			}
			return year;
		}
867143
def delay_2(year):
    ''''''

    last = delay_1(year - 1)
    present = delay_1(year)
    next_ = delay_1(year + 1)

    if next_ - present == 356:
        return 2
    elif present - last == 382:
        return 1
    else:
        return 0
403493
def years_before(year = 0)
      Age.new(birthday: birthday, present_day: present_day.prev_year(year))
    end
317215
private double convertMaturity(int maturityInMonths) {
		Schedule schedule = fixMetaSchedule.generateSchedule(referenceDate, maturityInMonths, 12);
		return schedule.getFixing(0);
	}
909847
private int newYear(int gyear) {

        long cacheValue = newYearCache.get(gyear);

        if (cacheValue == CalendarCache.EMPTY) {

            int solsticeBefore= winterSolstice(gyear - 1);
            int solsticeAfter = winterSolstice(gyear);
            int newMoon1 = newMoonNear(solsticeBefore + 1, true);
            int newMoon2 = newMoonNear(newMoon1 + SYNODIC_GAP, true);
            int newMoon11 = newMoonNear(solsticeAfter + 1, false);
            
            if (synodicMonthsBetween(newMoon1, newMoon11) == 12 &&
                (hasNoMajorSolarTerm(newMoon1) || hasNoMajorSolarTerm(newMoon2))) {
                cacheValue = newMoonNear(newMoon2 + SYNODIC_GAP, true);
            } else {
                cacheValue = newMoon2;
            }

            newYearCache.put(gyear, cacheValue);
        }
        return (int) cacheValue;
    }
398419
@Override
    protected PlainDate getDate0(int year) {

        int month = this.getMonth().getValue();
        int dayOfMonth = GregorianMath.getLengthOfMonth(year, month) + 1 + this.domIndicator;
        int ref = GregorianMath.getDayOfWeek(year, month, dayOfMonth);
        PlainDate result = PlainDate.of(year, month, dayOfMonth);

        if (ref == this.dayOfWeek) {
            return result;
        }

        int delta = (this.dayOfWeek - ref);

        if (delta > 0) {
            delta -= 7;
        }

        return result.plus(delta, DAYS);

    }
1253050
static void formatYear(
        StringBuilder sb,
        int year
    ) {

        int value = year;

        if (value < 0) {
            sb.append('-');
            value = Math.negateExact(year);
        }

        if (value >= 10000) {
            if (year > 0) {
                sb.append('+');
            }
        } else if (value < 1000) {
            sb.append('0');
            if (value < 100) {
                sb.append('0');
                if (value < 10) {
                    sb.append('0');
                }
            }
        }

        sb.append(value);

    }
1143014
protected static int yearFrom2Digits(int shortYear, int currentYear) {
        if (shortYear < 100) {
            shortYear += currentYear - (currentYear % 100);
            if (Math.abs(shortYear - currentYear) >= 50) {
                if (shortYear < currentYear) {
                    return shortYear + 100;
                } else {
                    return shortYear - 100;
                }
            }
        }
        return shortYear;
    }
68215
function() {
        for (var p=0;p<this.pages.length;++p) {
            var cal = this.pages[p];
            cal.previousYear();
        }
    }