code: def GetDateRangeWithOrigins(self):
      
      period_list = self.GetServicePeriodList()
      ranges = [period.GetDateRange() for period in period_list]
      starts = filter(lambda x: x, [item[0] for item in ranges])
      ends = filter(lambda x: x, [item[1] for item in ranges])
  
      if not starts or not ends:
        return (None, None, None, None)
  
      minvalue, minindex = min(itertools.izip(starts, itertools.count()))
      maxvalue, maxindex = max(itertools.izip(ends, itertools.count()))
  
      minreason = (period_list[minindex].HasDateExceptionOn(minvalue) and
                   "earliest service exception date in calendar_dates.txt" or
                   "earliest service date in calendar.txt")
  
      maxreason = (period_list[maxindex].HasDateExceptionOn(maxvalue) and
                   "last service exception date in calendar_dates.txt" or
                   "last service date in calendar.txt")
  
      # Override with feed_info.txt feed_start_date and feed_end_date values, if
      # defined
      if self.feed_info and self.feed_info.feed_start_date:
        minvalue = self.feed_info.feed_start_date
        minreason = "feed_start_date in feed_info.txt"
      if self.feed_info and self.feed_info.feed_end_date:
        maxvalue = self.feed_info.feed_end_date
        maxreason = "feed_end_date in feed_info.txt"
  
      return (minvalue, maxvalue, minreason, maxreason)
docs: Returns a tuple of (earliest, latest, earliest_origin, latest_origin)
      dates on which the service periods in the schedule define service, in
      YYYYMMDD form.
      The origins specify where the earliest or latest dates come from. In
      particular, whether the date is a regular ServicePeriod start_date or
      end_date in calendar.txt, a service exception of type add in
      calendar_dates.txt, or feed start/end date defined in feed_info.txt.