:param ref_time: datetime/string, 需要判断的时间变量
    :param start_time: string, 时间区间上限
    :param end_time: string, 时间下限
    :return: 判断某个时间是否在限定的时间范围内
424013
def is_within_hour_range(ref_time, start_time, end_time):
    
    str_ref_time = ref_time.strftime('%Y%m%d')
    start_time_ = mktime(strptime(str_ref_time + '-' + start_time, '%Y%m%d-%H:%M'))
    end_time_ = mktime(strptime(str_ref_time + '-' + end_time, '%Y%m%d-%H:%M'))
    ref_time_ = mktime(ref_time.timetuple())
    if start_time_ <= ref_time_ <= end_time_:
        return True
    else:
        return False
839288
def get_dataset_end_date_as_datetime(self):
        # type: () -> Optional[datetime]
        
        dataset_date = self.data.get('dataset_date', None)
        if dataset_date:
            if '-' in dataset_date:
                dataset_date = dataset_date.split('-')[1]
                return datetime.strptime(dataset_date, '%m/%d/%Y')
        return None
439942
def get_start_and_end_time(self, ref=None):
        
        now = time.localtime(ref)
        if self.syear == 0:
            self.syear = now.tm_year
        day_start = find_day_by_offset(self.syear, self.smon, self.smday)
        start_time = get_start_of_day(self.syear, self.smon, day_start)

        if self.eyear == 0:
            self.eyear = now.tm_year
        day_end = find_day_by_offset(self.eyear, self.emon, self.emday)
        end_time = get_end_of_day(self.eyear, self.emon, day_end)

        now_epoch = time.mktime(now)
        if start_time > end_time:  # the period is between years
            if now_epoch > end_time:
                # check for next year
                day_end = find_day_by_offset(self.eyear + 1, self.emon, self.emday)
                end_time = get_end_of_day(self.eyear + 1, self.emon, day_end)
            else:
                # it s just that start was the last year
                day_start = find_day_by_offset(self.syear - 1, self.smon, self.emday)
                start_time = get_start_of_day(self.syear - 1, self.smon, day_start)
        else:
            if now_epoch > end_time:
                # just have to check for next year if necessary
                day_start = find_day_by_offset(self.syear + 1, self.smon, self.smday)
                start_time = get_start_of_day(self.syear + 1, self.smon, day_start)
                day_end = find_day_by_offset(self.eyear + 1, self.emon, self.emday)
                end_time = get_end_of_day(self.eyear + 1, self.emon, day_end)

        return (start_time, end_time)
850785
def getTime(self):
        
        T = 1/float(self.samp[self.nrates-1])
        endtime = self.endsamp[self.nrates-1] * T

        t = numpy.linspace(0,endtime,self.endsamp[self.nrates-1])

        return t
776879
def start_time(self):
        
        resource_list = self.traffic_incident()
        start_time = namedtuple('start_time', 'start_time')
        if len(resource_list) == 1 and resource_list[0] is None:
            return None
        else:
            try:
                return [start_time(resource['start'])
                        for resource in resource_list]
            except (KeyError, TypeError):
                return [start_time(resource['StartTimeUTC'])
                        for resource in resource_list]
582399
function formatTimeString_(time, endTime) {
  var ret = '';
  if (time) {
    ret += (time.getTime() - time.getTimezoneOffset() * 60000);
  }
  if (endTime) {
    ret += ', ' + (endTime.getTime() - endTime.getTimezoneOffset() * 60000);
  }
  return ret;
}
471800
def start_time_f day
      #puts "start #{start_time} : #{start_time.class} #{start_time.to_date} #{day}"
      if dtstart.class == Date
        # whole day
        ""
      elsif start_time.to_date == day.to_date
        start_time.strftime('%H:%M')
      else
        "..."
      end
    end
452425
def get_start_and_end_times(
    feed: "Feed", date: Optional[str] = None
) -> List[str]:
    
    st = feed.get_stop_times(date)
    return (
        st["departure_time"].dropna().min(),
        st["arrival_time"].dropna().max(),
    )
1219806
function (startTime, endTime, callback) {
    var self = this;

    self._request({
      path: urlJoin(_urlPrefix, 'usage'),
      qs: {
        startTime: typeof startTime === 'Date' ? startTime.toISOString() : startTime,
        endTime: typeof endTime === 'Date' ? endTime.toISOString() : endTime
      }
    }, function (err, body) {
      return callback(err, body);
    });
  }
869093
def timeOneSearch(queryString):
    
    startTime = time.clock()
    resultString = backend.runSearchVariants(queryString)
    endTime = time.clock()
    elapsedTime = endTime - startTime
    return resultString, elapsedTime
374361
def _time_query_parms(begin_time, end_time):
        """"""
        query_parms = []
        if begin_time is not None:
            begin_ts = timestamp_from_datetime(begin_time)
            qp = 'begin-time={}'.format(begin_ts)
            query_parms.append(qp)
        if end_time is not None:
            end_ts = timestamp_from_datetime(end_time)
            qp = 'end-time={}'.format(end_ts)
            query_parms.append(qp)
        query_parms_str = '&'.join(query_parms)
        if query_parms_str:
            query_parms_str = '?' + query_parms_str
        return query_parms_str
647206
def convert_time_stamp_to_date(content):
    ''''''
    start_time_stamp = content.get('startTime')
    end_time_stamp = content.get('endTime')
    if start_time_stamp:
        start_time = datetime.datetime.utcfromtimestamp(start_time_stamp // 1000).strftime("%Y/%m/%d %H:%M:%S")
        content['startTime'] = str(start_time)
    if end_time_stamp:
        end_time = datetime.datetime.utcfromtimestamp(end_time_stamp // 1000).strftime("%Y/%m/%d %H:%M:%S")
        content['endTime'] = str(end_time)
    return content
682507
def set_end(self,time):
    
    self.add_var_opt('gps-end-time', time)
    self.__end = time
    self.__set_output()
1187453
def find_missing_taf_times(lines: [dict], start: Timestamp, end: Timestamp) -> [dict]:  # type: ignore
    
    if not lines:
        return lines
    # Assign start time
    lines[0]['start_time'] = start
    # Fix other times
    last_fm_line = 0
    for i, line in enumerate(lines):
        if _is_tempo_or_prob(line['type']):
            continue
        last_fm_line = i
        # Search remaining lines to fill empty end or previous for empty start
        for target, other, direc in (('start', 'end', -1), ('end', 'start', 1)):
            target += '_time'
            if not line[target]:
                line[target] = _get_next_time(lines[i::direc][1:], other + '_time')
    # Special case for final forcast
    if last_fm_line:
        lines[last_fm_line]['end_time'] = end
    # Reset original end time if still empty
    if lines and not lines[0]['end_time']:
        lines[0]['end_time'] = end
    return lines
227949
def end_time(self):
        """"""
        try:
            return self.start_time + SCAN_DURATION[self.sector]
        except KeyError:
            return self.start_time
846446
def set_end(self,time,pass_to_command_line=True):
    
    if pass_to_command_line:
      self.add_var_opt('gps-end-time',time)
    self.__end = time
    self.__data_end = time
814384
def getByTime(self, startTime=None, endTime=None):
        
        collections = self.get_data_collections()

        if startTime is not None:
            startTime = float(startTime)
        if endTime is not None:
            endTime = float(endTime)

        if startTime is not None and endTime is not None:
            timeQuery = {"$and": [{"timestamps": {"$gt": startTime}},
                                  {"timestamps": {"$lt": endTime}}]}
        elif startTime is not None and endTime is None:
            timeQuery = {"timestamps": {"$gt": startTime}}
        elif startTime is None and endTime is not None:
            timeQuery = {"timestamps": {"$lt": endTime}}

        IDs = []

        for coll in collections:
            docs = self.noteDB[coll].find(timeQuery, {"ID": 1, "_id": 0})
            for doc in docs:
                IDs.append(doc['ID'])

        return IDs