Find the earliest date with the most trips
183401
def read_busiest_date(path: str) -> Tuple[datetime.date, FrozenSet[str]]:
    """"""
    feed = load_raw_feed(path)
    return _busiest_date(feed)
72471
private static int search(
        long utcDays,
        long[] firstOfMonth
    ) {

        int low = 0;
        int high = firstOfMonth.length - 1;

        while (low <= high) {
            int middle = (low + high) / 2;

            if (firstOfMonth[middle] <= utcDays) {
                low = middle + 1;
            } else {
                high = middle - 1;
            }
        }

        return low - 1;

    }
188356
def check_in_bounds(self, date):
        '''
        '''
        dt = Timestamp(date)
        return ((self._lbound is None or dt >= self._lbound) and
                (self._rbound is None or dt <= self._rbound))
619441
def where_entry_date(query, datespec):
    
    date, interval, _ = utils.parse_date(datespec)
    start_date, end_date = date.span(interval)

    return orm.select(
        e for e in query if
        e.local_date >= start_date.naive and
        e.local_date <= end_date.naive
    )
1137821
def max_date(self, symbol):
        
        res = self._collection.find_one({SYMBOL: symbol}, projection={ID: 0, END: 1},
                                        sort=[(START, pymongo.DESCENDING)])
        if res is None:
            raise NoDataFoundException("No Data found for {}".format(symbol))
        return utc_dt_to_local_dt(res[END])
764746
def active(self):
        """"""
        qs = self.get_queryset()
        return qs.filter(
            models.Q(
                models.Q(start_date__isnull=True) |
                models.Q(start_date__lte=now().date())
            ) &
            models.Q(
                models.Q(end_date__isnull=True) |
                models.Q(end_date__gte=now().date())
            )
        ).distinct()
488238
def query_dated(num=8, kind='1'):
        '''
        
        '''
        return TabPost.select().where(
            TabPost.kind == kind
        ).order_by(
            TabPost.time_update.asc()
        ).limit(num)
495448
def entries(self, start = None, end = None):
        ''''''
        if not start:
            start = self.earliest_record
        if not end:
            end = self.latest_record
        fr = start.strftime('%Y%m%d')
        to = end.strftime('%Y%m%d')
        url = str.format(
            'projects/{}/entries?from={}&to={}',
            self.id,
            fr,
            to,
        )
        response = self.hv.get_request(url)
        return [Entry(self.hv, ej['day_entry']) for ej in response]
82050
def _GenerateStopTimesTuples(self):
    """"""
    stoptimes = self.GetStopTimes()
    for i, st in enumerate(stoptimes):
      yield st.GetFieldValuesTuple(self.trip_id)
880033
def journey_options(origin:      str,
                    destination: str,
                    via:         t.Optional[str]=None,
                    before:      t.Optional[int]=None,
                    after:       t.Optional[int]=None,
                    time:        t.Optional[datetime]=None,
                    hsl:         t.Optional[bool]=None,
                    year_card:   t.Optional[bool]=None) -> (
                        snug.Query[t.List[Journey]]):
    """"""
    return snug.GET('treinplanner', params={
        'fromStation':     origin,
        'toStation':       destination,
        'viaStation':      via,
        'previousAdvices': before,
        'nextAdvices':     after,
        'dateTime':        time,
        'hslAllowed':      hsl,
        'yearCard':        year_card,
    })
1061393
function findOutNearestDate(x0, d0, d1){
            return (new Date(x0).getTime() - new Date(d0.date).getTime()) > (new Date(d1.date).getTime() - new Date(x0).getTime()) ? d0 : d1;
        }
1217028
def _calculate_bounds(self):
        """"""
        # get start datetime
        first = self.coll_handle.find_one(None, sort=[("ts", ASCENDING)])
        last = self.coll_handle.find_one(None, sort=[("ts", DESCENDING)])

        self._start = first['ts']
        if self._start.tzinfo is None:
            self._start = self._start.replace(tzinfo=tzutc())

        self._end = last['ts']
        if self._end.tzinfo is None:
            self._end = self._end.replace(tzinfo=tzutc())

        return True
1074449
def query_recent_most(num=8, recent=30):
        '''
        
        '''
        time_that = int(time.time()) - recent * 24 * 3600
        return TabPost.select().where(
            TabPost.time_update > time_that
        ).order_by(
            TabPost.view_count.desc()
        ).limit(num)
40107
private long findMaxTimestamp() {
        if (!isInit) {
            init();
        }
        long max = 0;
        for (int i = 0; i < allNodes.length; i++) {
            if (allNodes[i] != null && allNodes[i].getLastTimestamp() > max) {
                max = allNodes[i].getLastTimestamp();
            }
        }
        return max;
    }
55642
def getDueDate(self):
        """"""
        due_dates = map(lambda an: an.getDueDate, self.getAnalyses())
        return due_dates and min(due_dates) or None
867779
def read_trip_counts_by_date(path: str) -> Dict[datetime.date, int]:
    """"""
    feed = load_raw_feed(path)
    return _trip_counts_by_date(feed)
511747
def _most_restrictive(date_elems):
    
    most_index = len(DATE_ELEMENTS)
    for date_elem in date_elems:
        if date_elem in DATE_ELEMENTS and DATE_ELEMENTS.index(date_elem) < most_index:
            most_index = DATE_ELEMENTS.index(date_elem)
    if most_index < len(DATE_ELEMENTS):
        return DATE_ELEMENTS[most_index]
    else:
        raise KeyError('No least restrictive date element found')