return the lowest or highest possible year which fits the value
760675
function osmDateParser (value, options) {
  var m, v, g

  m = value.match(/^(.*)\.\.(.*)$/)
  if (m) {
    let s = osmDateParser(m[1])
    let e = osmDateParser(m[2])
    if (s === null || e === null) {
      return null
    }
    if (s[0] > e[1]) {
      return null
    }
    return [ s[0], e[1] ]
  }

  m = value.match(/^(\d*) BCE?$/i)
  if (m) {
    [ v, g ] = parseDate(value)
    return [ v, v ]
  }

  m = value.match(/^before (.*)$/i)
  if (m) {
    [ v, g ] = parseDate(m[1])
    return [ null, v - 1 ]
  }

  m = value.match(/^after (.*)$/i)
  if (m) {
    [ v, g ] = parseDate(m[1])
    return [ v + g, null ]
  }

  m = value.match(/^early (.*)$/i)
  if (m) {
    [ v, g ] = parseDate(m[1])
    return [ v, Math.round(v + g * 0.33) ]
  }

  m = value.match(/^mid (.*)$/i)
  if (m) {
    [ v, g ] = parseDate(m[1])
    return [ Math.round(v + g * 0.33), Math.round(v + g * 0.67 - 1) ]
  }

  m = value.match(/^late (.*)$/i)
  if (m) {
    [ v, g ] = parseDate(m[1])
    return [ Math.round(v + g * 0.67 - 1), v + g - 1 ]
  }

  m = parseDate(value)
  if (m) {
    [ v, g ] = m
    return [ v, v + g - 1 ]
  }

  return null
}
771248
def repval(self, limitsok=False):
        """"""

        if not limitsok and self.dkind in ('lower', 'upper'):
            raise LimitError()

        if self.dkind == 'unif':
            lower, upper = map(float, self.data)
            v = 0.5 * (lower + upper)
        elif self.dkind in _noextra_dkinds:
            v = float(self.data)
        elif self.dkind in _yesextra_dkinds:
            v = float(self.data[0])
        else:
            raise RuntimeError('can\'t happen')

        if self.tkind == 'log10':
            return 10**v
        return v
216086
function(year) {
			var last = this._delay1(year - 1);
			var present = this._delay1(year);
			var next = this._delay1(year + 1);
			return ((next - present) === 356 ? 2 : ((present - last) === 382 ? 1 : 0));
		}
137637
def daterange(self):
        

        return daterange(
            lower=self.lower,
            upper=self.upper,
            lower_inc=self.lower_inc,
            upper_inc=self.upper_inc)
1093157
def aroon_down(data, period):
    
    catch_errors.check_for_period_error(data, period)
    period = int(period)

    a_down = [((period -
            list(reversed(data[idx+1-period:idx+1])).index(np.min(data[idx+1-period:idx+1]))) /
            float(period)) * 100 for idx in range(period-1, len(data))]
    a_down = fill_for_noncomputable_vals(data, a_down)
    return a_down
961106
def __findRange(self, excelLib, start, end):
        '''  '''
        inc = 1
        low = 0
        high = 0
        dates = excelLib.readCol(0, 1)

        for index, date in enumerate(dates):
            if int(start) <= int(date):
                low = index + inc
                break

        if low:
            for index, date in reversed(list(enumerate(dates))):
                if int(date) <= int(end):
                    high = index + inc
                    break

        return low, high
766829
def is_year(self):
        """"""
        dt = DATA_TYPES['year']
        if dt['min'] and dt['max']:
            if type(self.data) is dt['type'] and dt['min'] < self.data < dt['max']:
                self.type = 'year'.upper()
                self.len = None
                return True
14744
def _min(self):
        """"""
        return (
            self.range[0] if (self.range and self.range[0] is not None) else
            (min(self._values) if self._values else None)
        )
1210477
function() {
	   var value = this.el.value;
	
		var separator = this.options.dateFormat.match(/[^Ymd ]/g)[0];
	   var ladate = value.split(separator);
	   if( ladate.length != 3) { return false; }
	   if ( isNaN(parseInt(ladate[0],10)) || isNaN(parseInt(ladate[1],10)) || isNaN(parseInt(ladate[2],10))) { return false; }
	   var formatSplit = this.options.dateFormat.split(separator);
	   var yearIndex = inputEx.indexOf('Y',formatSplit);
	   if (ladate[yearIndex].length!=4) { return false; } // Avoid 3-digits years...
	   var d = parseInt(ladate[ inputEx.indexOf('d',formatSplit) ],10);
	   var Y = parseInt(ladate[yearIndex],10);
	   var m = parseInt(ladate[ inputEx.indexOf('m',formatSplit) ],10)-1;
	   var unedate = new Date(Y,m,d);
	   var annee = unedate.getFullYear();
	   return ((unedate.getDate() == d) && (unedate.getMonth() == m) && (annee == Y));
	}
1214258
def years_match(data, years):
    
    years = [years] if isinstance(years, int) else years
    dt = datetime.datetime
    if isinstance(years, dt) or isinstance(years[0], dt):
        error_msg = "`year` can only be filtered with ints or lists of ints"
        raise TypeError(error_msg)
    return data.isin(years)
200549
def y2k(year: int) -> int:
    ''''''
    assert 0 <= year <= 99, 'Not a two digit year {}'.format(year)
    return year + 1000 if year >= 69 else year + 2000
862994
def _clip(value, lower, upper):
    
    return lower if value < lower else upper if value > upper else value
11000
public function year($value = null)
    {
        if ($value !== null) {
            if ($value < 0 || $value > 9999) {
                $this->year = 0;
            } else {
                $this->year = $value;
            }
        }
        return $this->year;
    }
1179216
def as_float(self):
        '''
        '''
        if not self.year:
            return None
        out = float(self.year.replace('?', '9'))
        if self.month:
            # TODO: we are assuming months are of equal length
            out += float(self.month.replace('?', '0')) / 12.0
            if self.day:
                out += float(self.day.replace('?', '0')) / 365.0
        return out
1257235
function maxSatisfying (versions, range) {
  return versions
    .filter(function (v) { return satisfies(v, range) })
    .sort(compare)
    .pop()
}
71056
def _is_leap_year(year):
    
    isleap = ((np.mod(year, 4) == 0) &
              ((np.mod(year, 100) != 0) | (np.mod(year, 400) == 0)))
    return isleap
1185375
@SuppressWarnings("fallthrough")
    protected int handleGetLimit(int field, int limitType) {
        switch (field) {
        case ERA:
            if (limitType == MINIMUM || limitType == GREATEST_MINIMUM) {
                return 0;
            }
            return CURRENT_ERA;
        case YEAR:
        {
            switch (limitType) {
            case MINIMUM:
            case GREATEST_MINIMUM:
                return 1;
            case LEAST_MAXIMUM:
                return 1;
            case MAXIMUM:
                return super.handleGetLimit(field, MAXIMUM) - ERAS[CURRENT_ERA*3];
            }
            //Fall through to the default if not handled above
        }
        default:
            return super.handleGetLimit(field, limitType);
        }
    }