Find the earliest week with the most trips
963203
def read_busiest_week(path: str) -> Dict[datetime.date, FrozenSet[str]]:
    """"""
    feed = load_raw_feed(path)
    return _busiest_week(feed)
1241217
function _cleanArrivals(results) {
    // List of Arrivals to Keep
    let arrivals = [];

    // Get unique arrivals
    let arrivalTimes = [];
    for ( let i = 0; i < results.length; i++ ) {
      if ( arrivalTimes.indexOf(results[i].destination.arrival.toTimestamp()) === -1 ) {
        arrivalTimes.push(results[i].destination.arrival.toTimestamp());
      }
    }

    // Pick best Trip for each arrival
    for ( let i = 0; i < arrivalTimes.length; i++ ) {
      let arrivalTime = arrivalTimes[i];
      let arrival = undefined;

      // Get Trips with arrival time
      for ( let j = 0; j < results.length; j++ ) {
        let result = results[j];
        if ( result.destination.arrival.toTimestamp() === arrivalTime ) {
          if ( arrival === undefined )  {
            arrival = result;
          }
          else if ( result.origin.departure.toTimestamp() > arrival.origin.departure.toTimestamp() ) {
            arrival = result;
          }
          else if ( result.origin.departure.toTimestamp() === arrival.origin.departure.toTimestamp() && result.length < arrival.length ) {
            arrival = result;
          }
        }
      }

      // Add arrival to list
      arrivals.push(arrival);

    }

    // Return arrivals
    return arrivals;
  }
1003764
public function endOfWeek()
    {
        if ($this->getDayOfWeek() !== static::$weekEndsAt) {
            return $this->next(static::$weekEndsAt)->endOfDay();
        }

        return $this->endOfDay();
    }
1075687
public static boolean isSaturday(int column, int firstDayOfWeek) {
        return (firstDayOfWeek == Time.SUNDAY && column == 6)
                || (firstDayOfWeek == Time.MONDAY && column == 5)
                || (firstDayOfWeek == Time.SATURDAY && column == 0);
    }
54825
public function endOfWeek()
        {
            if ($this->dayOfWeek != self::SUNDAY) $this->next(self::SUNDAY);

            return $this->endOfDay();
        }
877489
def move_datetime_week(dt, direction, num_shifts):
    
    delta = relativedelta(weeks=+num_shifts)
    return _move_datetime(dt, direction, delta)
670012
def trips(self):
    """"""
    trips = set()
    for route in self.routes():
      trips |= route.trips()
    return trips
286778
def get_all_days():
    
    weekly = get_weekly()
    daily = get_daily()

    return [w * (d / 100.0) for w in weekly for d in daily]
1261310
function possiblyCachedWeekData(dt) {
  if (dt.weekData === null) {
    dt.weekData = gregorianToWeek(dt.c);
  }
  return dt.weekData;
}
781231
def previous_week_day(base_date, weekday):
    
    day = base_date - timedelta(days=1)
    while day.weekday() != weekday:
        day = day - timedelta(days=1)
    return day
573594
def weekly(date=datetime.date.today()):
    
    return date - datetime.timedelta(days=date.weekday())
638023
def _ssweek_of_month(date_value):
    ""
    weekday_of_first = (date_value.replace(day=1).weekday() + 1) % 7
    return (date_value.day + weekday_of_first - 1) // 7
893603
def stops(self):
    """"""
    serves = set()
    for trip in self.trips():
      for stop_time in trip.stop_times():
        serves |= stop_time.stops()
    return serves
1311477
def find_best_periods(self, n_periods=5, return_scores=False):
        """"""
        return self.optimizer.find_best_periods(self, n_periods,
                                                return_scores=return_scores)
638100
def trips(self, val):
        
        self._trips = val
        if val is not None and not val.empty:
            self._trips_i = self._trips.set_index("trip_id")
        else:
            self._trips_i = 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)
1065352
def this_week():
        
        since = TODAY + delta(weekday=MONDAY(-1))
        until = since + delta(weeks=1)
        return Date(since), Date(until)