Formulate the specific query needed for download

        Not intended to be called by developers directly.

        :param as_of: Date in 'YYYYMMDD' format
        :type as_of: string
515273
def _download_query(self, as_of):
        
        c = self.institution.client()
        q = c.bank_account_query(
            number=self.number,
            date=as_of,
            account_type=self.account_type,
            bank_id=self.routing_number)
        return q
163234
def _build_search_query(self, from_date):
        

        sort = [{self._sort_on_field: {"order": "asc"}}]

        filters = []
        if self._repo:
            filters.append({"term": {"origin": self._repo}})

        if from_date:
            filters.append({"range": {self._sort_on_field: {"gte": from_date}}})

        if filters:
            query = {"bool": {"filter": filters}}
        else:
            query = {"match_all": {}}

        search_query = {
            "query": query,
            "sort": sort
        }

        return search_query
4748
def _get_id(owner, date, content):
    
    h = hashlib.sha256()
    # Hash still contains the original project url, keep as is
    h.update("github.com/spacetelescope/asv".encode('utf-8'))
    for x in content:
        if x is None:
            h.update(",".encode('utf-8'))
        else:
            h.update(x.encode('utf-8'))
        h.update(",".encode('utf-8'))

    if date is None:
        date = datetime.datetime(1970, 1, 1)
    return "tag:{0},{1}:/{2}".format(owner, date.strftime('%Y-%m-%d'), h.hexdigest())
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)
131102
def _get_library_metadata(self, date_range):
        
        if date_range is None:
            raise Exception("A date range must be provided")
        if not (date_range.start and date_range.end):
            raise Exception("The date range {0} must contain a start and end date".format(date_range))

        start = date_range.start if date_range.start.tzinfo is not None else date_range.start.replace(tzinfo=mktz())
        end = date_range.end if date_range.end.tzinfo is not None else date_range.end.replace(tzinfo=mktz())
        query = {'$or': [{'start': {'$lte': start}, 'end': {'$gte': start}},
                         {'start': {'$gte': start}, 'end': {'$lte': end}},
                         {'start': {'$lte': end}, 'end': {'$gte': end}}]}

        cursor = self._collection.find(query,
                                       projection={'library_name': 1, 'start': 1, 'end': 1},
                                       sort=[('start', pymongo.ASCENDING)])

        results = []
        for res in cursor:
            start = res['start']
            if date_range.start.tzinfo is not None and start.tzinfo is None:
                start = start.replace(tzinfo=mktz("UTC")).astimezone(tz=date_range.start.tzinfo)

            end = res['end']
            if date_range.end.tzinfo is not None and end.tzinfo is None:
                end = end.replace(tzinfo=mktz("UTC")).astimezone(tz=date_range.end.tzinfo)

            results.append(TickStoreLibrary(res['library_name'], DateRange(start, end, CLOSED_CLOSED)))
        return results
980594
def download(self, days=60):
        
        days_ago = datetime.datetime.now() - datetime.timedelta(days=days)
        as_of = time.strftime("%Y%m%d", days_ago.timetuple())
        query = self._download_query(as_of=as_of)
        response = self.institution.client().post(query)
        return StringIO(response)
814819
def date(fmt=None,timestamp=None):
    ""
    if fmt=='U': # return timestamp
        t = datetime.datetime.now()
        return int(time.mktime(t.timetuple()))
    if fmt=='c': # return isoformat 
        d = datetime.datetime.fromtimestamp(timestamp)
        return d.isoformat()
    if fmt=='Ymd':
        d = datetime.datetime.now()
        return d.strftime("%Y%m%d")
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")]
322742
def request_timestamp(self):
        
        amz_date = self.query_parameters.get(_x_amz_date)
        if amz_date is not None:
            amz_date = amz_date[0]
        else:
            amz_date = self.headers.get(_x_amz_date)
            if amz_date is None:
                date = self.headers.get(_date)
                if date is None:
                    raise AttributeError("Date was not passed in the request")

                # This isn't really valid -- seems to be a bug in the AWS
                # documentation.
                if _iso8601_timestamp_regex.match(date):
                    amz_date = date # pragma: nocover
                else:
                    # Parse this as an HTTP date and reformulate it.
                    amz_date = (datetime.strptime(date, _http_date_format)
                                .strftime("%Y%m%dT%H%M%SZ"))
        if not _iso8601_timestamp_regex.match(amz_date):
            raise AttributeError("X-Amz-Date parameter is not a valid ISO8601 "
                                 "string: %r" % amz_date)

        return amz_date
615354
@Deprecated
	public static String getDateStringMMDDYYYY(Date date) {
		if(date==null) return "";
		Calendar C=Calendar.getInstance();
		C.setTime(date);
		int day=C.get(Calendar.DATE);
		int month=C.get(Calendar.MONTH)+1;
		return
			(month>=0 && month<=9 ? "0":"")
			+month
			+(day>=0 && day<=9 ? "0":"")
			+day
			+C.get(Calendar.YEAR)
		;
	}
1108016
def as_of(self, date):
        
        if not self.instance:
            return self._as_of_set(date)
        queryset = self.get_queryset().filter(history_date__lte=date)
        try:
            history_obj = queryset[0]
        except IndexError:
            raise self.instance.DoesNotExist(
                "%s had not yet been created." % self.instance._meta.object_name
            )
        if history_obj.history_type == "-":
            raise self.instance.DoesNotExist(
                "%s had already been deleted." % self.instance._meta.object_name
            )
        return history_obj.instance
701382
def valid_at(self, valid_date):
        ''''''
        is_valid = db.Q(validity__end__gt=valid_date,
                        validity__start__lte=valid_date)
        no_validity = db.Q(validity=None)
        return self(is_valid | no_validity)
727221
def validate_iso_date key, value, opts
      if opts[:iso_date]
        return value.strftime("%Y-%m-%d")  if value.respond_to?(:strftime)
      end
      value
    end
326102
def semantic_date_tag(date, options = {})
      SemanticDateTimeTags::Tag::Date.new(date, options).to_html
    end
234915
def download(to_date = nil)
      url = to_date ? @url + "?to=#{to_date.strftime('%Y-%m-%d')}" : @url
      res = Curl::Easy.perform(url)
      code = res.response_code
      raise("Failed loading data from GitHub: #{url} #{code}") if code != 200
      html = Nokogiri::HTML(res.body_str)
      html.css('.day').map do |x|
        x.attributes.values_at('data-date', 'data-count').map(&:value)
      end
    end
874447
def _get_date_range_query(self, start_date, end_date, timespan= 'DAY', date_field= None):
        '''
        
        '''
        if date_field is None:
            date_field = self._date_field
        query ={'q':'*:*',
                'rows':0,
                'facet':'true',
                'facet.range': date_field,
                'facet.range.gap': '+1{}'.format(timespan),
                'facet.range.end': '{}'.format(end_date),
                'facet.range.start': '{}'.format(start_date),
                'facet.range.include': 'all'
                }
        if self._per_shard:
            query['distrib'] = 'false'
        return query
115071
def build_date(self):
        
        # pylint: disable=len-as-condition
        if len(self.dutinformation) > 0 and (self.dutinformation.get(0).build is not None):
            return self.dutinformation.get(0).build.date
        return None