Given a list of times that follow a word such as ``about``,
    we return a list of times that could appear in the query as a result
    of this. For example if ``about 7pm`` appears in the utterance, then
    we also want to add ``1830`` and ``1930``.
177560
def get_approximate_times(times: List[int]) -> List[int]:
    
    approximate_times = []
    for time in times:
        hour = int(time/HOUR_TO_TWENTY_FOUR) % 24
        minute = time % HOUR_TO_TWENTY_FOUR
        approximate_time = datetime.now()
        approximate_time = approximate_time.replace(hour=hour, minute=minute)

        start_time_range = approximate_time - timedelta(minutes=30)
        end_time_range = approximate_time + timedelta(minutes=30)
        approximate_times.extend([start_time_range.hour * HOUR_TO_TWENTY_FOUR + start_time_range.minute,
                                  end_time_range.hour * HOUR_TO_TWENTY_FOUR + end_time_range.minute])

    return approximate_times
195365
def contains(self, time: datetime.datetime,
                 inclusive: bool = True) -> bool:
        
        if inclusive:
            return self.start <= time <= self.end
        else:
            return self.start < time < self.end
628483
def include?(tod)
      second = tod.to_i
      second += TimeOfDay::NUM_SECONDS_IN_DAY if second < @range.first
      @range.cover?(second)
    end
19501
def addToTimeVary(self,*params):
        '''
        
        '''
        for param in params:
            if param not in self.time_vary:
                self.time_vary.append(param)
1060070
def previous_occurrences(num, from)
      from = TimeUtil.match_zone(from, start_time) or raise ArgumentError, "Time required, got #{from.inspect}"
      return [] if from <= start_time
      a = enumerate_occurrences(start_time, from - 1).to_a
      a.size > num ? a[-1*num,a.size] : a
    end
1069476
def later_than(after, before):
    
    if isinstance(after, six.string_types):
        after = str_to_time(after)
    elif isinstance(after, int):
        after = time.gmtime(after)

    if isinstance(before, six.string_types):
        before = str_to_time(before)
    elif isinstance(before, int):
        before = time.gmtime(before)

    if before is None:
        return True
    if after is None:
        return False
    return after >= before
30067
def last_time_non_ok_or_up(self):
        
        non_ok_times = [x for x in [self.last_time_down]
                        if x > self.last_time_up]
        if not non_ok_times:
            last_time_non_ok = 0  # todo: program_start would be better?
        else:
            last_time_non_ok = min(non_ok_times)
        return last_time_non_ok
635025
def parse_profile_date(text, suppress=False):
  
  try:
    if text == u"Unknown" or text == u"?" or text == u"Not available":
      return None
    if text == u"Now":
      return datetime.datetime.now()

    seconds_match = re.match(r'(?P<seconds>[0-9]+) second(s)? ago', text)
    if seconds_match:
      return datetime.datetime.now() - datetime.timedelta(seconds=int(seconds_match.group(u'seconds')))

    minutes_match = re.match(r'(?P<minutes>[0-9]+) minute(s)? ago', text)
    if minutes_match:
      return datetime.datetime.now() - datetime.timedelta(minutes=int(minutes_match.group(u'minutes')))

    hours_match = re.match(r'(?P<hours>[0-9]+) hour(s)? ago', text)
    if hours_match:
      return datetime.datetime.now() - datetime.timedelta(hours=int(hours_match.group(u'hours')))

    today_match = re.match(r'Today, (?P<hour>[0-9]+):(?P<minute>[0-9]+) (?P<am>[APM]+)', text)
    if today_match:
      hour = int(today_match.group(u'hour'))
      minute = int(today_match.group(u'minute'))
      am = today_match.group(u'am')
      if am == u'PM' and hour < 12:
        hour += 12
      today = datetime.date.today()
      return datetime.datetime(year=today.year, month=today.month, day=today.day, hour=hour, minute=minute, second=0)

    yesterday_match = re.match(r'Yesterday, (?P<hour>[0-9]+):(?P<minute>[0-9]+) (?P<am>[APM]+)', text)
    if yesterday_match:
      hour = int(yesterday_match.group(u'hour'))
      minute = int(yesterday_match.group(u'minute'))
      am = yesterday_match.group(u'am')
      if am == u'PM' and hour < 12:
        hour += 12
      yesterday = datetime.date.today() - datetime.timedelta(days=1)
      return datetime.datetime(year=yesterday.year, month=yesterday.month, day=yesterday.day, hour=hour, minute=minute, second=0)

    try:
      return datetime.datetime.strptime(text, '%m-%d-%y, %I:%M %p')
    except ValueError:
      pass
    # see if it's a date.
    try:
      return datetime.datetime.strptime(text, '%m-%d-%y').date()
    except ValueError:
      pass
    try:
      return datetime.datetime.strptime(text, '%Y-%m-%d').date()
    except ValueError:
      pass
    try:
      return datetime.datetime.strptime(text, '%Y-%m-00').date()
    except ValueError:
      pass
    try:
      return datetime.datetime.strptime(text, '%Y-00-00').date()
    except ValueError:
      pass
    try:
      return datetime.datetime.strptime(text, '%B %d, %Y').date()
    except ValueError:
      pass
    try:
      return datetime.datetime.strptime(text, '%b %d, %Y').date()
    except ValueError:
      pass
    try:
      return datetime.datetime.strptime(text, '%Y').date()
    except ValueError:
      pass
    try:
      return datetime.datetime.strptime(text, '%b %d, %Y').date()
    except ValueError:
      pass
    # see if it's a month/year pairing.
    return datetime.datetime.strptime(text, '%b %Y').date()
  except:
    if suppress:
      return None
    raise
1162589
def time_around(&block)
        start = Time.now
        rslt = block.call
        query_log("#{aop_context[:class].name}##{aop_context[:method]}", "elapsed time = #{Time.now - start} [s]")
        rslt
      end
584447
def what_time_is_it(self, message):
        """"""
        now = datetime.datetime.now()
        self.say("It's %s." % self.to_natural_day_and_time(now, with_timezone=True), message=message)
456824
def n_day(date_string):
        
        today = datetime.date.today()
        match = re.match(r'(\d{1,3}|a) days? ago', date_string)
        groups = match.groups()
        if groups:
            decrement = groups[0]
            if decrement == 'a':
                decrement = 1
            return today - datetime.timedelta(days=int(decrement))
        return None
1203389
def include?(value)
      if first.is_a?(TimeWithZone)
        cover?(value)
      elsif last.is_a?(TimeWithZone)
        cover?(value)
      else
        super
      end
    end
894742
def time_question_features(self, text):
        
        features = {}

        # A list of all words from the known sentences
        all_words = " ".join(self.positive + self.negative).split()

        # A list of the first word in each of the known sentence
        all_first_words = []
        for sentence in self.positive + self.negative:
            all_first_words.append(
                sentence.split(' ', 1)[0]
            )

        for word in text.split():
            features['first_word({})'.format(word)] = (word in all_first_words)

        for word in text.split():
            features['contains({})'.format(word)] = (word in all_words)

        for letter in 'abcdefghijklmnopqrstuvwxyz':
            features['count({})'.format(letter)] = text.lower().count(letter)
            features['has({})'.format(letter)] = (letter in text.lower())

        return features
965966
def checkElementsOfTimeVaryAreLists(self):
        
        for param in self.time_vary:
            assert type(getattr(self,param))==list,param + ' is not a list, but should be' + \
                                                   ' because it is in time_vary'
331620
def occurring_at?(time)
      time = TimeUtil.match_zone(time, start_time) or raise ArgumentError, "Time required, got #{time.inspect}"
      if duration > 0
        return false if exception_time?(time)
        occurs_between?(time - duration + 1, time)
      else
        occurs_at?(time)
      end
    end
1051715
def _dates(p_word_before_cursor):
    
    to_absolute = lambda s: relative_date_to_date(s).isoformat()

    start_value_pos = p_word_before_cursor.find(':') + 1
    value = p_word_before_cursor[start_value_pos:]

    for reldate in date_suggestions():
        if not reldate.startswith(value):
            continue

        yield Completion(reldate, -len(value), display_meta=to_absolute(reldate))
491273
function( text ) {
			if(modules.utils.isString(text)){
				text = text.toLowerCase();
				text = modules.utils.trim( text );
				// start with timezone char
				if( text.match(':') && ( modules.utils.startWith(text, 'z') || modules.utils.startWith(text, '-')  || modules.utils.startWith(text, '+') )) {
					return true;
				}
				// has ante meridiem or post meridiem
				if( text.match(/^[0-9]/) &&
					( this.hasAM(text) || this.hasPM(text) )) {
					return true;
				}
				// contains time delimiter but not datetime delimiter
				if( text.match(':') && !text.match(/t|\s/) ) {
					return true;
				}

				// if it's a number of 2, 4 or 6 chars
				if(modules.utils.isNumber(text)){
					if(text.length === 2 || text.length === 4 || text.length === 6){
						return true;
					}
				}
			}
			return false;
		}