Return the date_elem that has the most restrictive range from date_elems
511747
def _most_restrictive(date_elems):
    
    most_index = len(DATE_ELEMENTS)
    for date_elem in date_elems:
        if date_elem in DATE_ELEMENTS and DATE_ELEMENTS.index(date_elem) < most_index:
            most_index = DATE_ELEMENTS.index(date_elem)
    if most_index < len(DATE_ELEMENTS):
        return DATE_ELEMENTS[most_index]
    else:
        raise KeyError('No least restrictive date element found')
878416
def time_range(self,flag=None):
        '''
        
        '''
        if self.count==0: return [[None,None],[None,None]]
        
        if flag is None : return cnes_convert([self.date.min(),self.date.max()])
        else : return cnes_convert([self.date.compress(flag).min(),self.date.compress(flag).max()])
1299166
def ImportTrafficRestrictions(self, restrictions_file):
    ""
    ParseDate = lambda x: datetime.date(int(x[:4]), int(x[4:6]), int(x[6:8]))
    MonthNr = lambda x: int(x[:4]) * 12 + int(x[4:6])
    for schedule, id, bitmask, start_date, end_date in  \
    ReadCSV(restrictions_file,
            ['FPL_KUERZEL', 'VB', 'VB_DATUM', 'DATUM_VON', 'DATUM_BIS']):
      id = u"VB%s.%s" % (schedule, id)
      bitmask = bitmask.strip()
      dates = {}

      # This is ugly as hell, I know. I briefly explain what I do:
      # 8 characters in the bitmask equal a month ( 8 * 4bits = 32, no month has
      # more than 31 days, so it's ok).
      # Then I check if the current day of the month is in the bitmask (by
      # shifting the bit by x days and comparing it to the bitmask).
      # If so I calculate back what year month and actual day I am in
      # (very disgusting) and mark that date...
      for i in range(MonthNr(end_date) - MonthNr(start_date)+1):
        mask=int(bitmask[i*8:i*8+8], 16)
        for d in range(32):
          if 1 << d & mask:
            year=int(start_date[0:4])+ ((int(start_date[4:6]) + i -1 )) / 12
            month=((int(start_date[4:6]) + i-1 ) % 12) +1
            day=d+1
            cur_date = str(year)+("0"+str(month))[-2:]+("0"+str(day))[-2:]
            dates[int(cur_date)] = 1
      self.services[id] = dates.keys()
      self.services[id].sort()
1339214
def is_date_ranges_intersection(t1start, t1end, t2start, t2end):
    
    return (t1start <= t2start <= t1end) or (t2start <= t1start <= t2end)
967962
private I_CmsListDateRestriction parseRange(CmsXmlContentValueLocation dateRestriction) {

        CmsXmlContentValueLocation location = dateRestriction.getSubValue(N_RANGE);
        if (location == null) {
            return null;
        }
        CmsXmlContentValueLocation fromLoc = location.getSubValue(N_FROM);
        CmsXmlContentValueLocation toLoc = location.getSubValue(N_TO);
        Date fromDate = parseDate(fromLoc);
        Date toDate = parseDate(toLoc);
        if ((fromDate != null) || (toDate != null)) {
            return new CmsListDateRangeRestriction(fromDate, toDate);
        } else {
            return null;
        }
    }
593560
def normalize_date_aggressively(date):
    """"""
    def _strip_last_part(date):
        parts = date.split('-')
        return '-'.join(parts[:-1])

    fake_dates = {'0000', '9999'}
    if date in fake_dates:
        return None
    try:
        return normalize_date(date)
    except ValueError:
        if '-' not in date:
            raise
        else:
            new_date = _strip_last_part(date)
            return normalize_date_aggressively(new_date)
186066
def date(self) -> Optional[DateHeader]:
        """"""
        try:
            return cast(DateHeader, self[b'date'][0])
        except (KeyError, IndexError):
            return None
455735
def daterange_with_details(value):
    ''''''
    delta = value.end - value.start
    start, end = None, None
    if is_first_year_day(value.start) and is_last_year_day(value.end):
        start = value.start.year
        if delta.days > 365:
            end = value.end.year
    elif is_first_month_day(value.start) and is_last_month_day(value.end):
        start = short_month(value.start)
        if delta.days > 31:
            end = short_month(value.end)
    else:
        start = short_day(value.start)
        if value.start != value.end:
            end = short_day(value.end)
    return _('%(start)s to %(end)s', start=start, end=end) if end else start
861959
def dates_in_range(start_date, end_date):
    
    return [
        start_date + timedelta(n)
        for n in range(int((end_date - start_date).days))
    ]
912551
function to (date, term) {
  if (!term) {
    return null;
  }
  var se = this.getRange(date, term);
  return se ? se.to : null;
}
1234438
def QA_util_date_gap(date, gap, methods):
    '''
    
    '''
    try:
        if methods in ['>', 'gt']:
            return trade_date_sse[trade_date_sse.index(date) + gap]
        elif methods in ['>=', 'gte']:
            return trade_date_sse[trade_date_sse.index(date) + gap - 1]
        elif methods in ['<', 'lt']:
            return trade_date_sse[trade_date_sse.index(date) - gap]
        elif methods in ['<=', 'lte']:
            return trade_date_sse[trade_date_sse.index(date) - gap + 1]
        elif methods in ['==', '=', 'eq']:
            return date

    except:
        return 'wrong date'
15105
def _getFromDate(l, date):
    '''
    
    '''
    try:
        date = _toDate(date)
        i = _insertDateIndex(date, l) - 1
        if i == -1:
            return l[0]
        return l[i]
    except (ValueError, TypeError):
        # ValueError: date invalid / TypeError: date = None
        return l[0]
1336685
def where_entry_last(query, ref):
    
    return orm.select(
        e for e in query
        if e.local_date < ref.local_date or
        (e.local_date == ref.local_date and
         e.id <= ref.id
         )
    )
549642
function(elem) {
          if(util.isArray(elem)) {
            return (elem.length === 0);
          }
          if(elem instanceof Object) {
            if(util.isDate(elem)) {
              return false;
            }
            return (Object.getOwnPropertyNames(elem).length === 0);
          }
          return false;
        }
1275428
function filterDay(arr, year, month, disabledDateObj) {
  const minDateTime = new Date(year, month, 1).getTime();
  const maxDateTime = new Date(year, month + 1, 0).getTime();
  const dayRangeArr = getDateRangeArr(disabledDateObj, minDateTime, maxDateTime);
  const dayArr = [];
  dayRangeArr.forEach((item) => {
    let { start, end } = item;
    start = new Date(start).getDate();
    end = new Date(end).getDate();
    for (let i = start; i <= end; i++) {
      dayArr.push(i);
    }
  });
  return arr.filter((item) => {
    const day = item.value;
    return dayArr.indexOf(day) === -1;
  });
}
488238
def query_dated(num=8, kind='1'):
        '''
        
        '''
        return TabPost.select().where(
            TabPost.kind == kind
        ).order_by(
            TabPost.time_update.asc()
        ).limit(num)
1107704
def set_date_bounds(self, date):
        '''
        
        '''
        if date is not None:
            split = date.split('~')
            if len(split) == 1:
                self._lbound = ts2dt(date)
                self._rbound = ts2dt(date)
            elif len(split) == 2:
                if split[0] != '':
                    self._lbound = ts2dt(split[0])
                if split[1] != '':
                    self._rbound = ts2dt(split[1])
            else:
                raise Exception('Date %s is not in the correct format' % date)