Returns a guess of the start and end dates for given semester.
169447
def get_semester_start_end(year, season):
    
    if season == Semester.SPRING:
        start_month, start_day = 1, 20
        end_month, end_day = 5, 17
    elif season == Semester.SUMMER:
        start_month, start_day = 5, 25
        end_month, end_day = 8, 16
    else:
        start_month, start_day = 8, 24
        end_month, end_day = 12, 20

    return date(year, start_month, start_day), date(year, end_month, end_day)
614484
public function guess_end() {
        global $DB;

        if ($this->get_total_logs() === 0) {
            // No way to guess if there are no logs.
            $this->endtime = 0;
            return $this->endtime;
        }

        list($filterselect, $filterparams) = $this->course_students_query_filter('ula');

        // Consider the course open if there are still student accesses.
        $monthsago = time() - (WEEKSECS * 4 * 2);
        $select = $filterselect . ' AND timeaccess > :timeaccess';
        $params = $filterparams + array('timeaccess' => $monthsago);
        $sql = "SELECT DISTINCT timeaccess FROM {user_lastaccess} ula
                  JOIN {enrol} e ON e.courseid = ula.courseid
                  JOIN {user_enrolments} ue ON e.id = ue.enrolid AND ue.userid = ula.userid
                 WHERE $select";
        if ($records = $DB->get_records_sql($sql, $params)) {
            return 0;
        }

        $sql = "SELECT DISTINCT timeaccess FROM {user_lastaccess} ula
                  JOIN {enrol} e ON e.courseid = ula.courseid
                  JOIN {user_enrolments} ue ON e.id = ue.enrolid AND ue.userid = ula.userid
                 WHERE $filterselect AND ula.timeaccess != 0
                 ORDER BY timeaccess DESC";
        $studentlastaccesses = $DB->get_fieldset_sql($sql, $filterparams);
        if (empty($studentlastaccesses)) {
            return 0;
        }
        sort($studentlastaccesses);

        return $this->median($studentlastaccesses);
    }
762961
private SortedSet<Date> calculateDates() {

        if (null == m_allDates) {
            SortedSet<Date> result = new TreeSet<>();
            if (isAnyDatePossible()) {
                Calendar date = getFirstDate();
                int previousOccurrences = 0;
                while (showMoreEntries(date, previousOccurrences)) {
                    result.add(date.getTime());
                    toNextDate(date);
                    previousOccurrences++;
                }
            }
            m_allDates = result;
        }
        return m_allDates;
    }
613212
public Date getStart()
   {
      Date result = null;
      for (ResourceAssignment assignment : m_assignments)
      {
         if (result == null || DateHelper.compare(result, assignment.getStart()) > 0)
         {
            result = assignment.getStart();
         }
      }
      return (result);
   }
1140760
protected List<AcademicTermDetail> getAcademicTermsAfter(DateTime start) {
        final List<AcademicTermDetail> terms =
                this.eventAggregationManagementDao.getAcademicTermDetails();
        final int index =
                Collections.binarySearch(
                        terms,
                        new AcademicTermDetailImpl(
                                start.toDateMidnight(), start.plusDays(1).toDateMidnight(), ""));
        if (index > 0) {
            return terms.subList(index, terms.size());
        } else if (index < 0) {
            return terms.subList(-(index + 1), terms.size());
        }
        return terms;
    }
311328
function() {
		// counting that dates were sorted in initialization
		var date = this.events[0].start_date;
		if (this.eras && this.eras.length > 0) {
			if (this.eras[0].start_date.isBefore(date)) {
				return this.eras[0].start_date;
			}
		}
		return date;

	}
102396
def get_dates_in_period(start=None, top=None, step=1, step_dict={}):
    """"""

    delta = relativedelta(**step_dict) if step_dict else timedelta(days=step)

    start = start or datetime.today()
    top = top or start + delta
    dates = []
    current = start
    while current <= top:
        dates.append(current)
        current += delta
    return dates
475319
def initial_guesses(self):
        
        return np.array([param.value for param in self.model.params])
751972
def get_due(self, estimated):
        """"""
        due = 0
        due = round((estimated - datetime.utcnow()).seconds / 60)
        return due
7154
def _init_dates(self):
        
        if self.total_transactions == 0:
            return None
        self.epoch_start = Result.select(Result.epoch).order_by(Result.epoch.asc()).limit(1).get().epoch
        self.epoch_finish = Result.select(Result.epoch).order_by(Result.epoch.desc()).limit(1).get().epoch
        self.start_datetime = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(self.epoch_start))
        self.finish_datetime = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(self.epoch_finish))
392041
public Date getStartDate()
   {
      Date startDate = null;

      for (Task task : m_tasks)
      {
         //
         // If a hidden "summary" task is present we ignore it
         //
         if (NumberHelper.getInt(task.getUniqueID()) == 0)
         {
            continue;
         }

         //
         // Select the actual or forecast start date. Note that the
         // behaviour is different for milestones. The milestone end date
         // is always correct, the milestone start date may be different
         // to reflect a missed deadline.
         //
         Date taskStartDate;
         if (task.getMilestone() == true)
         {
            taskStartDate = task.getActualFinish();
            if (taskStartDate == null)
            {
               taskStartDate = task.getFinish();
            }
         }
         else
         {
            taskStartDate = task.getActualStart();
            if (taskStartDate == null)
            {
               taskStartDate = task.getStart();
            }
         }

         if (taskStartDate != null)
         {
            if (startDate == null)
            {
               startDate = taskStartDate;
            }
            else
            {
               if (taskStartDate.getTime() < startDate.getTime())
               {
                  startDate = taskStartDate;
               }
            }
         }
      }

      return (startDate);
   }
325327
function guessEra(jdn, JD_AM = JD_EPOCH_OFFSET_AMETE_MIHRET, JD_AA = JD_EPOCH_OFFSET_AMETE_ALEM) {
  return (jdn >= (JD_AM + 365)) ? JD_AM : JD_AA;
}
1047505
function getDays(start, end = moment().startOf('day')) {
  let cursor = moment(start);
  let days = [];
  while (cursor.isBefore(end)) {
    days.push(cursor.format('YYYY-MM-DD'));
    cursor = cursor.add(1, 'd');
  }
  return days;
}
578078
def display(self):
        """"""
        if self.degree and self.school:
            disp = self.degree + u' from ' + self.school
        else:
            disp = self.degree or self.school or None
        if disp is not None and self.date_range is not None:
            disp += u' (%d-%d)' % self.date_range.years_range
        return disp or u''
1239283
public Date getEndDate()
    {
        if ((m_startTime != null) && (m_endTime != null))
        {
            if (m_endTime.before(m_startTime))
                return m_startTime;
        }
        return m_endTime;
    }
1110899
def imply_dates
      return unless !@properties['end'].nil? && !@properties['start'].nil?

      start_date = nil

      @properties['start'].each do |start_val|
        if start_val =~ /^(\d{4}-[01]\d-[0-3]\d)/
          start_date = Regexp.last_match(1) if start_date.nil?
        elsif start_val =~ /^(\d{4}-[0-3]\d\d)/
          start_date = Regexp.last_match(1) if start_date.nil?
        end
      end

      unless start_date.nil?
        @properties['end'].map! do |end_val|
          if end_val.match?(/^\d{4}-[01]\d-[0-3]\d/)
            end_val
          elsif end_val.match?(/^\d{4}-[0-3]\d\d/)
            end_val
          else
            start_date + ' ' + end_val
          end
        end
      end
    end
931209
def get_start_and_end_time(self, ref=None):
        
        now = time.localtime(ref)

        # If no year, it's our year
        if self.syear == 0:
            self.syear = now.tm_year
        month_start_id = now.tm_mon
        day_start = find_day_by_weekday_offset(self.syear,
                                               month_start_id, self.swday, self.swday_offset)
        start_time = get_start_of_day(self.syear, month_start_id, day_start)

        # Same for end year
        if self.eyear == 0:
            self.eyear = now.tm_year
        month_end_id = now.tm_mon
        day_end = find_day_by_weekday_offset(self.eyear, month_end_id, self.ewday,
                                             self.ewday_offset)
        end_time = get_end_of_day(self.eyear, month_end_id, day_end)

        # Maybe end_time is before start. So look for the
        # next month
        if start_time > end_time:
            month_end_id += 1
            if month_end_id > 12:
                month_end_id = 1
                self.eyear += 1
            day_end = find_day_by_weekday_offset(self.eyear,
                                                 month_end_id, self.ewday, self.ewday_offset)
            end_time = get_end_of_day(self.eyear, month_end_id, day_end)

        now_epoch = time.mktime(now)
        # But maybe we look not enought far. We should add a month
        if end_time < now_epoch:
            month_end_id += 1
            month_start_id += 1
            if month_end_id > 12:
                month_end_id = 1
                self.eyear += 1
            if month_start_id > 12:
                month_start_id = 1
                self.syear += 1
            # First start
            day_start = find_day_by_weekday_offset(self.syear,
                                                   month_start_id, self.swday, self.swday_offset)
            start_time = get_start_of_day(self.syear, month_start_id, day_start)
            # Then end
            day_end = find_day_by_weekday_offset(self.eyear,
                                                 month_end_id, self.ewday, self.ewday_offset)
            end_time = get_end_of_day(self.eyear, month_end_id, day_end)

        return (start_time, end_time)