Matches a wide variety of date ranges separated by '..' or '-'

 @param str [String] a string which may contain a date range
 @return [Array(String)] the begining and ending dates of an identified
    range
435713
def range_match(str)
      str = str.gsub('to', '-').gsub('until', '-')
      regexp = %r{
        ([a-zA-Z]{0,3}\s?[\d\-\/\.xu\?\~a-zA-Z]*,?\s?
        \d{3}[\d\-xs][s\d\-\.xu\?\~]*)
        \s*[-\.]+\s*
        ([a-zA-Z]{0,3}\s?[\d\-\/\.xu\?\~a-zA-Z]*,?\s?
        \d{3}[\d\-xs][s\d\-\.xu\?\~]*)
      }x
      regexp.match(str) do |m|
        [m[1], m[2]]
      end
    end
1258072
function matches(str, match) {
    if (Array.isArray(match)) {
        var l = match.length;
        for( var s=0; s < l; s++) {
            if ( mm(str,match[s])) {
                return true;
            }
        }
        return false;
    }
    return match.test(str);
}
469701
def validate_DATERANGE(value, restriction):
    
    if len(restriction) != 2:
        raise ValidationError("Template ERROR: Only two values can be specified in a date range.")

    if type(value) == pd.DataFrame:
        dates = [get_datetime(v) for v in list(value.index)]
    else:
        dates = value

    if type(dates) is list:
        for date in dates:
            validate_DATERANGE(date, restriction)
        return

    min_date = get_datetime(restriction[0])
    max_date = get_datetime(restriction[1])
    if value < min_date or value > max_date:
        raise ValidationError("DATERANGE: %s <%s> %s"%(min_date,value,max_date))
1110899
def imply_dates
      return unless !@properties['end'].nil? && !@properties['start'].nil?

      start_date = nil

      @properties['start'].each do |start_val|
        if start_val =~ /^(\d{4}-[01]\d-[0-3]\d)/
          start_date = Regexp.last_match(1) if start_date.nil?
        elsif start_val =~ /^(\d{4}-[0-3]\d\d)/
          start_date = Regexp.last_match(1) if start_date.nil?
        end
      end

      unless start_date.nil?
        @properties['end'].map! do |end_val|
          if end_val.match?(/^\d{4}-[01]\d-[0-3]\d/)
            end_val
          elsif end_val.match?(/^\d{4}-[0-3]\d\d/)
            end_val
          else
            start_date + ' ' + end_val
          end
        end
      end
    end
546021
def as_dates(self):
        
        new_start = self.start.date() if self.start and isinstance(self.start, datetime.datetime) else self.start
        new_end = self.end.date() if self.end and isinstance(self.end, datetime.datetime) else self.end
        return DateRange(new_start, new_end, CLOSED_CLOSED)
500726
def fill_date_range(start_date, end_date, date_format=None):
    

    if date_format:
        start_date = datetime.strptime(start_date, date_format).date()
        end_date = datetime.strptime(end_date, date_format).date()
    date_list = []
    while start_date <= end_date:
        date_list.append(start_date)
        start_date = start_date + timedelta(days=1)
    return date_list
655738
def days_range(first=None, second=None, wipe=False):
    
    _first, _second = parse(first), parse(second)
    (_start, _end) = (_second, _first) if _first > _second else (_first, _second)
    days_between = (_end - _start).days
    date_list = [_end - datetime.timedelta(days=x) for x in range(0, days_between + 1)]
    if wipe and len(date_list) >= 2:
        date_list = date_list[1:-1]
    return date_list
698721
def get_dates(raw_table) -> "list of dates":
        
        dates = []
        found_first = False
        for i, dstr in enumerate([raw_table[i][0] for i in range(0, len(raw_table))]):
            if dstr:
                if len(dstr.split("/")) == 3:
                    d = datetime.datetime.strptime(dstr, '%m/%d/%Y')
                elif len(dstr.split("-")) == 3:
                    d = datetime.datetime.strptime(dstr, '%Y-%m-%d')
                else:
                    # Not necessarily an error, could just be a non-date cell
                    logging.debug("unknown date-format: {}".format(dstr))
                    continue
                dates.append(d)
                if not found_first:
                    found_first = True
                    logging.debug("Found first date: '{}' at i: {}".format(d.isoformat(), i))
            elif found_first:
                logging.debug("Last date: {}".format(d))
                break
        return dates
697214
private boolean containsDate(String[] strs, int tolerance)
    {
        dfirst = -1;
        dlast = -1;
        int lastdw = -999;
        int lastnum = -999;
        int lastyear = -999;
        for (int i = 0; i < strs.length; i++)
        {
            if (isMonthName(strs[i]))
            {
                lastdw = i;
                if (lastdw - lastnum <= tolerance)
                    return true;
            }
            else if (isYear(strs[i]))
            {
                lastyear = i;
                if (lastyear - lastnum <= tolerance)
                    return true;
            }
            else if (isNum(strs[i]))
            {
                lastnum = i;
                if (lastnum - lastdw <= tolerance)
                    return true;
            }
        }
        return false;
    }
523891
def parse_date(date_str: str, pattern=_RE_DATE) -> dt.date:
    """"""

    groups = re.match(pattern, date_str)

    return dt.date(*_date_to_tuple(groups.groupdict()))
822681
function parseDate( str ) {
	var v = Date.parse( str );
	if ( isnan( v ) ) {
		return new TypeError( 'invalid value. Unable to parse string as a date. Value: `' + str + '`.' );
	}
	return new Date( v );
}
408142
def date_range_for_webtrends(cls, start_at=None, end_at=None):
        
        if start_at and end_at:
            start_date = cls.parse_standard_date_string_to_date(
                start_at)
            end_date = cls.parse_standard_date_string_to_date(
                end_at)
            return [(
                cls.parse_date_for_query(start_date),
                cls.parse_date_for_query(end_date))]
        else:
            return [("current_hour-1", "current_hour-1")]
171560
def str_dateStrip(astr_datestr, astr_sep='/'):
  
  try:
    index = astr_datestr.index(astr_sep)
  except:
    return astr_datestr.encode('ascii')

  try:
    tm = time.strptime(astr_datestr, '%d/%M/%Y')
  except:
    try:
      tm = time.strptime(astr_datestr, '%d/%M/%y')
    except:
      error_exit('str_dateStrip', 'parsing date string',
                 'no conversion was possible', 1)
  tstr = time.strftime("%d%M%Y", tm)
  return tstr.encode('ascii')
611659
def get_period(date_from: date, date_to: date) -> str:
    
    assert isinstance(date_from, date)
    assert isinstance(date_to, date)

    str_from: str = date_from.isoformat()
    str_to: str = date_to.isoformat()

    return str_from + " - " + str_to
1051086
def circa(str)
      run = str.gsub!(/.*c[irca\.]*/i, '')
      run ||= str.gsub!(/.*about/i, '')
      date = parse(str) if run

      return nil if date.nil?

      # The EDTF grammar does not support uncertainty on masked precision dates
      if date.respond_to? :uncertain!
        date.uncertain!
      elsif date.is_a? EDTF::Interval
        # Interval uncertainty is scoped to the begin and end dates;
        # to be safe, we mark both.
        date.from = date.from.uncertain! if date.from.respond_to? :uncertain!
        date.to   = date.to.uncertain!   if date.to.respond_to? :uncertain!
      end

      date
    end
97783
def _close_open_date_ranges(self, record):
        """"""
        date_ranges = (('beginDate', 'endDate'),)
        for begin, end in date_ranges:
            if begin in record and end in record:
                return
            elif begin in record:
                record[end] = record[begin]
            elif end in record:
                record[begin] = record[end]
93606
def slice first, last
      if first.is_a?(Integer) && last.is_a?(Integer)
        DateTimeIndex.new(to_a[first..last], freq: @offset)
      else
        first = Helper.find_date_string_bounds(first)[0] if first.is_a?(String)
        last  = Helper.find_date_string_bounds(last)[1] if last.is_a?(String)

        slice_between_dates first, last
      end
    end