take date and return bhavcopy url
358795
def get_bhavcopy_url(self, d):
        """"""
        d = parser.parse(d).date()
        day_of_month = d.strftime("%d")
        mon = d.strftime("%b").upper()
        year = d.year
        url = self.bhavcopy_base_url % (year, mon, day_of_month, mon, year)
        return url
282849
function isLeap (date) {
  var year;
  if (typeof date === 'number') {
    year = date;
  } else {
    date = this.toDate(date);
    year = date.getFullYear();
  }
  return new Date(year, 1, 29).getDate() === 29;
}
686452
def fetch_appl():
    """"""
    yql = YQL('AAPL', '2014-01-01', '2014-01-10')

    for item in yql:
        print item.get('date'), item.get('price')

    yql.select('AAPL', '2014-01-01', '2014-01-10')

    for item in yql:
        print item.get('date'), item.get('price')
65061
function dateStrGetter(name, width, form, extended) {
    if (form === void 0) { form = FormStyle.Format; }
    if (extended === void 0) { extended = false; }
    return function (date, locale) {
        return getDateTranslation(date, locale, name, width, form, extended);
    };
}
1274956
def get_url(self, obj, view_name, request, format):
        
        # Unsaved objects will not yet have a valid URL.
        if hasattr(obj, 'pk') and obj.pk is None:
            return None

        lookup_value = getattr(obj, self.lookup_field)
        kwargs = {self.lookup_url_kwarg: lookup_value}
        return self.reverse(view_name, kwargs=kwargs, request=request, format=format)
1361889
function sgTrackingUrlMapper(url, data) {
  // In our development system urls start with /php/shopgate/ always
  const developmentPath = '/php/shopgate/';
  const appRegex = /sg_app_resources\/[0-9]*\//;

  // Build regex that will remove all blacklisted paramters
  let regex = '';
  urlParameterBlacklist.forEach((entry) => {
    regex += `((\\?|^){0,1}(${entry}=.*?(&|$)))`;
    regex += '|';
  });
  const params = url.indexOf('?') !== -1 ? url.split('?')[1] : '';
  let urlParams = params.replace(new RegExp(regex, 'g'), '');
  urlParams = urlParams === '' ? '' : `?${urlParams.replace(/&$/, '')}`;

  // Get rid of hash and app urls
  let urlPath = url.split('?')[0].split('#')[0].replace(appRegex, '');

  // Get path from url
  if (url.indexOf(developmentPath) !== -1) {
    urlPath = urlPath.substring(urlPath.indexOf(developmentPath) + developmentPath.length);
  } else if (urlPath.indexOf('http') !== -1) {
    urlPath = urlPath.substring(urlPath.indexOf('/', urlPath.indexOf('//') + 2) + 1);
  } else {
    urlPath = urlPath.substring(1);
  }

  // Get action from path
  const action = urlPath.substring(
    0,
    ((urlPath.indexOf('/') !== -1) ? (urlPath.indexOf('/')) : undefined)
  );

  // If no mapping function is available for the action, continue
  if (typeof mapping[action] === 'undefined') {
    return {
      public: urlPath + urlParams,
      private: action,
    };
  }

  // Call mapping function and return its result
  const pathWithoutAction = urlPath.substring(action.length + 1);
  let pathWithoutActionArray = [];

  if (pathWithoutAction.length !== 0) {
    pathWithoutActionArray = pathWithoutAction.split('/');
  }

  const mappedUrls = mapping[action](pathWithoutActionArray, data || {});

  if (Array.isArray(mappedUrls)) {
    return {
      public: mappedUrls[1] + urlParams,
      private: mappedUrls[0],
    };
  }

  return {
    public: mappedUrls + urlParams,
    private: mappedUrls,
  };
}
151041
def _get_url_params(self, shorten=True):
        """"""
        cable = True if self.category == 'cable' else False
        url_date = convert_month(self.date, shorten=shorten, cable=cable)

        return [
            BASE_URL,
            self.weekday.lower(),
            self.category + '-ratings',
            url_date.replace(' ', '-')
        ]
186066
def date(self) -> Optional[DateHeader]:
        """"""
        try:
            return cast(DateHeader, self[b'date'][0])
        except (KeyError, IndexError):
            return None
932214
def get_cgi_parameter_datetime(form: cgi.FieldStorage,
                               key: str) -> Optional[datetime.datetime]:
    
    try:
        s = get_cgi_parameter_str(form, key)
        if not s:
            # if you dateutil.parser.parse() an empty string,
            # you get today's date
            return None
        d = dateutil.parser.parse(s)
        if d.tzinfo is None:  # as it will be
            d = d.replace(tzinfo=dateutil.tz.tzlocal())
        return d
    except ValueError:
        return None
897993
public String makeReplayURI(String datespec, String url) {
		String replayURI = "";
		try {
			if(url.contains(hostPort)) {
				return url;
			}
			URI uri = new URI(url);
			StringBuilder sb = new StringBuilder(90);
			sb.append("http://");
			sb.append(datespec).append(".");
			sb.append(uri.getHost()).append(".");
			sb.append(hostPort);
			sb.append(uri.getPath());
			String query = uri.getQuery();
			if(query != null && query.length() > 0) {
				sb.append("?").append(query);
			}
			replayURI = sb.toString();

		} catch (URISyntaxException e) {
			e.printStackTrace();
		}
		return replayURI;
	}
726345
def _get_date(self, decrypted_content):
        """"""
        
        # Just copied from original KeePassX source
        date_field = struct.unpack('<5B', decrypted_content[:5])
        dw1 = date_field[0]
        dw2 = date_field[1]
        dw3 = date_field[2]
        dw4 = date_field[3]
        dw5 = date_field[4]

        y = (dw1 << 6) | (dw2 >> 2)
        mon = ((dw2 & 0x03) << 2) | (dw3 >> 6)
        d = (dw3 >> 1) & 0x1F
        h = ((dw3 & 0x01) << 4) | (dw4 >> 4)
        min_ = ((dw4 & 0x0F) << 2) | (dw5 >> 6)
        s = dw5 & 0x3F
        return datetime(y, mon, d, h, min_, s)
175148
function getWhatDay (date, day, mode) {
  date = toStringDate(date)
  if (baseExports.isDate(date) && !isNaN(day)) {
    date.setDate(date.getDate() + Number(day))
    if (mode === STRING_FIRST) {
      return new Date(_dateFullYear(date), _dateMonth(date), date.getDate())
    } else if (mode === STRING_LAST) {
      return new Date(getDateTime(getWhatDay(date, 1, STRING_FIRST)) - 1)
    }
  }
  return date
}
533989
def daily404detail(date, limit=None, return_format=None):
    
    uri = 'daily404detail'
    if date:
        try:
            uri = '/'.join([uri, date.strftime("%Y-%m-%d")])
        except AttributeError:
            uri = '/'.join([uri, date])
        if limit:
            uri = '/'.join([uri, str(limit)])
    return _get(uri, return_format)
1091624
def url(self):
        # type:() -> str
        
        url = "https://api.darksky.net/forecast/{key}/{lat},{lon}".format(key=self.api_key,
                                                                          lat=self.latitude,
                                                                          lon=self.longitude)

        if isinstance(self._date, datetime):
            url += ",{:%Y-%m-%dT%H:%M:%S}".format(self._date)

        url += "?units={}".format(self.units)

        if self.lang != "auto":
            url += "&lang={}".format(self.lang)

        if len(self._exclude) > 0:
            url += "&exclude="
            for e in self._exclude:
                url += "{},".format(e)
            url = url.strip(",")

        if self._extend:
            url += "&extend=hourly"

        return url
592326
def _get_delivery_date(row):
    """"""
    try:
        month = row.find('div', {'class': 'date-small'}).string
        day = row.find('div', {'class': 'date-num-large'}).string
    except AttributeError:
        return None
    try:
        return parse('{} {}'.format(month, day)).date()
    except ValueError:
        return None
204082
def portdate(port_number, date=None, return_format=None):
    
    uri = 'portdate/{number}'.format(number=port_number)
    if date:
        try:
            uri = '/'.join([uri, date.strftime("%Y-%m-%d")])
        except AttributeError:
            uri = '/'.join([uri, date])
    response = _get(uri, return_format)
    if 'bad port number' in str(response):
        raise Error('Bad port number, {number}'.format(number=port_number))
    else:
        return response
1054888
def download_bhavcopy(self, d):
        """"""
        # ex_url = "https://www.nseindia.com/content/historical/EQUITIES/2011/NOV/cm08NOV2011bhav.csv.zip"
        url = self.get_bhavcopy_url(d)
        filename = self.get_bhavcopy_filename(d)
        # response = requests.get(url, headers=self.headers)
        response = self.opener.open(Request(url, None, self.headers))
        zip_file_handle = io.BytesIO(response.read())
        zf = zipfile.ZipFile(zip_file_handle)
        try:
            result = zf.read(filename)
        except KeyError:
            result = zf.read(zf.filelist[0].filename)

        return result