Get the CPI value for a specific time. Defaults to today. This uses
        the closest method internally but sets limit to one day.
424306
def get(self, date=datetime.date.today(), country=None):
        
        if not country:
            country = self.country
        if country == "all":
            raise ValueError("You need to specify a country")
        if not isinstance(date, str) and not isinstance(date, int):
            date = date.year

        cpi = self.data.get(country.upper(), {}).get(str(date))
        if not cpi:
            raise ValueError("Missing CPI data for {} for {}".format(
                country, date))

        return CPIResult(date=date, value=cpi)
84494
def prevmonday(num):
    
    today = get_today()
    lastmonday = today - timedelta(days=today.weekday(), weeks=num)
    return lastmonday
538323
def get_now():
    
    if not get_current_request:
        return datetime.datetime.now()
    request = get_current_request()
    if request:
        openinghours_now = request.GET.get('openinghours-now')
        if openinghours_now:
            return datetime.datetime.strptime(openinghours_now, '%Y%m%d%H%M%S')
    return datetime.datetime.now()
731125
def select_day(self, day):
        

        def _select_day(day):
            return self.data.loc[day, slice(None)]

        try:
            return self.new(_select_day(day), self.type, self.if_fq)
        except:
            raise ValueError('QA CANNOT GET THIS Day {} '.format(day))
7921
def daily_returns(self):
        
        if self._static_unit_net_value == 0:
            return np.nan
        return 0 if self._static_unit_net_value == 0 else self.unit_net_value / self._static_unit_net_value - 1
675344
def get(self):
        """"""
        if self.timer() > self.deadline:
            self.value = None
        return self.value
909886
def _get_value_to_set_at_point(self, point):
        
        laste, lastv = None, None
        for e, v in self.schedule:
            if e == point:
                return v    # meet the exact boundary, return directly
            if e > point:
                break
            laste, lastv = e, v
        if laste is None or laste == e:
            # hasn't reached the first scheduled point, or reached the end of all scheduled points
            return None
        if self.interp is None:
            # If no interpolation, nothing to do.
            return None
        v = (point - laste) * 1. / (e - laste) * (v - lastv) + lastv
        return v
763101
def current_day():
    
    aoc_now = datetime.datetime.now(tz=AOC_TZ)
    if aoc_now.month != 12:
        log.warning("current_day is only available in December (EST)")
        return 1
    day = min(aoc_now.day, 25)
    return day
627098
def hold_price(self, datetime=None):
        

        def weights(x):
            if sum(x['amount']) != 0:
                return np.average(
                    x['price'],
                    weights=x['amount'],
                    returned=True
                )
            else:
                return np.nan

        if datetime is None:
            return self.history_table.set_index(
                'datetime',
                drop=False
            ).sort_index().groupby('code').apply(weights).dropna()
        else:
            return self.history_table.set_index(
                'datetime',
                drop=False
            ).sort_index().loc[:datetime].groupby('code').apply(weights
                                                               ).dropna()
1336950
def get_current(self, item=None, raw=False, start=None, end=None):
        
        item_indexer = slice(None)
        if item:
            item_indexer = self.items.get_loc(item)

        start_index = self._start_index
        end_index = self._pos

        # get inital date window
        where = slice(start_index, end_index)
        current_dates = self.date_buf[where]

        def convert_datelike_to_long(dt):
            if isinstance(dt, pd.Timestamp):
                return dt.asm8
            if isinstance(dt, datetime.datetime):
                return np.datetime64(dt)
            return dt

        # constrict further by date
        if start:
            start = convert_datelike_to_long(start)
            start_index += current_dates.searchsorted(start)

        if end:
            end = convert_datelike_to_long(end)
            _end = current_dates.searchsorted(end, 'right')
            end_index -= len(current_dates) - _end

        where = slice(start_index, end_index)

        values = self.buffer.values[item_indexer, where, :]
        current_dates = self.date_buf[where]

        if raw:
            # return copy so we can change it without side effects here
            return values.copy()

        major_axis = pd.DatetimeIndex(deepcopy(current_dates), tz='utc')
        if values.ndim == 3:
            return pd.Panel(values, self.items, major_axis, self.minor_axis,
                            dtype=self.dtype)

        elif values.ndim == 2:
            return pd.DataFrame(values, major_axis, self.minor_axis,
                                dtype=self.dtype)
1137730
private void setValueForItem(int index, int value) {
        if (index == HOUR_INDEX) {
            mCurrentHoursOfDay = value;
        } else if (index == MINUTE_INDEX) {
            mCurrentMinutes = value;
        } else if (index == AMPM_INDEX) {
            if (value == AM) {
                mCurrentHoursOfDay = mCurrentHoursOfDay % 12;
            } else if (value == PM) {
                mCurrentHoursOfDay = (mCurrentHoursOfDay % 12) + 12;
            }
        }
    }
561219
def value(self):
        
        if isinstance(self.raw_value, (datetime.datetime, datetime.date)):
            return self.raw_value.isoformat()
        elif isinstance(self.raw_value, (bool,)):
            return 'Yes' if self.raw_value else 'No'
        return self.raw_value
602205
def get_price(self):
        
        tick = self.get_ticks(lookback=1, as_dict=True)
        return None if tick is None else tick['last']
1110428
def __timestamp():
    """"""
    today = time.time()
    ret = struct.pack(b'=L', int(today))
    return ret
606409
private static int getTimeToLive(final Ticket ticket) {
        val expTime = ticket.getExpirationPolicy().getTimeToLive().intValue();
        if (TimeUnit.SECONDS.toDays(expTime) >= MAX_EXP_TIME_IN_DAYS) {
            LOGGER.warn("Any expiration time larger than [{}] days in seconds is considered absolute (as in a Unix time stamp) "
                + "anything smaller is considered relative in seconds.", MAX_EXP_TIME_IN_DAYS);

        }
        return expTime;
    }
972767
def get_seconds_until_next_day(now=None):
    
    if now is None:
        now = arrow.utcnow()
    return (now.ceil('day') - now).seconds
804057
public static long getLongWithCurrentDate(String value, String timezone) {
    if (Strings.isNullOrEmpty(value)) {
      return 0;
    }

    DateTime time = getCurrentTime(timezone);
    DateTimeFormatter dtFormatter = DateTimeFormat.forPattern(CURRENT_DATE_FORMAT).withZone(time.getZone());
    if (value.toUpperCase().startsWith(CURRENT_DAY)) {
      return Long
          .parseLong(dtFormatter.print(time.minusDays(Integer.parseInt(value.substring(CURRENT_DAY.length() + 1)))));
    }
    if (value.toUpperCase().startsWith(CURRENT_HOUR)) {
      return Long
          .parseLong(dtFormatter.print(time.minusHours(Integer.parseInt(value.substring(CURRENT_HOUR.length() + 1)))));
    }
    return Long.parseLong(value);
  }