repeats_on is an array of datemonthly indices.  For example,
 "the 21st and 22nd of every monthy" will produce repeats_on == [21, 22]
762707
def interpret_datemonthly_variant
      hash_for_occ_base = { type: :datemonthly, interval: interval }
      array_of_occurrences = []
      repeats_on.each do |date_of_month|
        h = { date_of_month: date_of_month }
        array_of_occurrences << hash_for_occ_base.merge(h)
      end
      array_of_occurrences
    end
303162
def mode_date(self, rows: List[Row], column: DateColumn) -> Date:
        
        most_frequent_list = self._get_most_frequent_values(rows, column)
        if not most_frequent_list:
            return Date(-1, -1, -1)
        most_frequent_value = most_frequent_list[0]
        if not isinstance(most_frequent_value, Date):
            raise ExecutionError(f"Invalid valus for mode_date: {most_frequent_value}")
        return most_frequent_value
538767
def monthdayscalendar(cls, year, month):
        """"""
        weeks = []
        week = []
        for day in NepCal.itermonthdays(year, month):
            week.append(day)
            if len(week) == 7:
                weeks.append(week)
                week = []
        if len(week) > 0:
            weeks.append(week)
        return weeks
698258
def rnd_date_array(self, size, start=date(1970, 1, 1), end=date.today()):
        
        if isinstance(start, string_types):
            start = self.str2date(start)
        if isinstance(end, string_types):
            end = self.str2date(end)
        if start > end:
            raise ValueError("start time has to be earlier than end time")

        return self.randn(size, self._rnd_date, start, end)
1179560
def rnd_datetime_array(size, start=datetime(1970, 1, 1), end=None):
    
    if end is None:
        end = datetime.now()
    start = parser.parse_datetime(start)
    end = parser.parse_datetime(end)
    _assert_correct_start_end(start, end)
    return _randn(size, _rnd_datetime, start, end)
1119166
def handle_rmn_sd_on(tokens, options)
      if tokens.size > 3
        month = tokens[2].get_tag(RepeaterMonthName)
        day = tokens[3].get_tag(ScalarDay).type
        token_range = 0..1
      else
        month = tokens[1].get_tag(RepeaterMonthName)
        day = tokens[2].get_tag(ScalarDay).type
        token_range = 0..0
      end

      return if month_overflow?(Chronic.now.year, month.index, day)

      handle_m_d(month, day, tokens[token_range], options)
    end
683119
function icalrecur_iterator_next() {
      var before = (this.last ? this.last.clone() : null);

      if ((this.rule.count && this.occurrence_number >= this.rule.count) ||
          (this.rule.until && this.last.compare(this.rule.until) > 0)) {

        //XXX: right now this is just a flag and has no impact
        //     we can simplify the above case to check for completed later.
        this.completed = true;

        return null;
      }

      if (this.occurrence_number == 0 && this.last.compare(this.dtstart) >= 0) {
        // First of all, give the instance that was initialized
        this.occurrence_number++;
        return this.last;
      }


      var valid;
      do {
        valid = 1;

        switch (this.rule.freq) {
        case "SECONDLY":
          this.next_second();
          break;
        case "MINUTELY":
          this.next_minute();
          break;
        case "HOURLY":
          this.next_hour();
          break;
        case "DAILY":
          this.next_day();
          break;
        case "WEEKLY":
          this.next_week();
          break;
        case "MONTHLY":
          valid = this.next_month();
          break;
        case "YEARLY":
          this.next_year();
          break;

        default:
          return null;
        }
      } while (!this.check_contracting_rules() ||
               this.last.compare(this.dtstart) < 0 ||
               !valid);

      // TODO is this valid?
      if (this.last.compare(before) == 0) {
        throw new Error("Same occurrence found twice, protecting " +
                        "you from death by recursion");
      }

      if (this.rule.until && this.last.compare(this.rule.until) > 0) {
        this.completed = true;
        return null;
      } else {
        this.occurrence_number++;
        return this.last;
      }
    }
584427
def monthdatescalendar(cls, year, month):
        
        weeks = []
        week = []
        for day in NepCal.itermonthdates(year, month):
            week.append(day)
            if len(week) == 7:
                weeks.append(week)
                week = []
        if len(week) > 0:
            weeks.append(week)
        return weeks
1315595
private void getWeeklyDates(Calendar calendar, int frequency, List<Date> dates)
   {
      int currentDay = calendar.get(Calendar.DAY_OF_WEEK);

      while (moreDates(calendar, dates))
      {
         int offset = 0;
         for (int dayIndex = 0; dayIndex < 7; dayIndex++)
         {
            if (getWeeklyDay(Day.getInstance(currentDay)))
            {
               if (offset != 0)
               {
                  calendar.add(Calendar.DAY_OF_YEAR, offset);
                  offset = 0;
               }
               if (!moreDates(calendar, dates))
               {
                  break;
               }
               dates.add(calendar.getTime());
            }

            ++offset;
            ++currentDay;

            if (currentDay > 7)
            {
               currentDay = 1;
            }
         }

         if (frequency > 1)
         {
            offset += (7 * (frequency - 1));
         }
         calendar.add(Calendar.DAY_OF_YEAR, offset);
      }
   }
1124921
def repeat(nx=1, ny=1, nz=1)
      
      raise "Not a periodic system." if self.lattice_vectors.nil?
      
      u = self.copy
      v1 = self.lattice_vectors[0]
      v2 = self.lattice_vectors[1]
      v3 = self.lattice_vectors[2]

      nx_sign = (0 < nx) ? 1 : -1
      ny_sign = (0 < ny) ? 1 : -1
      nz_sign = (0 < nz) ? 1 : -1
      
      new_atoms = []
      nx.to_i.abs.times do |i|        
        ny.to_i.abs.times do |j|
          nz.to_i.abs.times do |k|
            new_atoms << self.displace(nx_sign*i*v1[0] + ny_sign*j*v2[0] + nz_sign*k*v3[0], 
                                       nx_sign*i*v1[1] + ny_sign*j*v2[1] + nz_sign*k*v3[1], 
                                       nx_sign*i*v1[2] + ny_sign*j*v2[2] + nz_sign*k*v3[2]).atoms
          end
        end
      end

      u.atoms = new_atoms.flatten
      u.lattice_vectors = [Vector[nx.abs*v1[0], nx.abs*v1[1], nx.abs*v1[2]], 
                           Vector[ny.abs*v2[0], ny.abs*v2[1], ny.abs*v2[2]], 
                           Vector[nz.abs*v3[0], nz.abs*v3[1], nz.abs*v3[2]]]
      # u.make_bonds 
      return u     
    end
626927
function(weekBeginDate) {
        var overlaps = false;
        var nextWeek = this.add(weekBeginDate, this.DAY, 6);
        if (nextWeek.getMonth() != weekBeginDate.getMonth()) {
            overlaps = true;
        }
        return overlaps;
    }
890041
def periodicity(self) -> str:
        
        periodicity = self._data['periodicity']
        return self.random.choice(periodicity)
462184
def get_upcoming_event_lists_for_the_remainder_of_the_month(self, year = None, month = None):
        ''''''

        events = []
        if year == None and month == None:
            now = datetime.now(tz=self.timezone) # timezone?
        else:
            now = datetime(year=year, month=month, day=1, hour=0, minute=0, second=0, tzinfo=self.timezone)

        # Get today's events, including past events
        start_time = datetime(year=now.year, month=now.month, day=now.day, hour=0, minute=0, second=0, tzinfo=self.timezone)
        end_time = datetime(year = start_time.year, month = start_time.month, day = start_time.day, hour=23, minute=59, second=59, tzinfo=self.timezone)
        events.append(self.get_events(start_time.isoformat(), end_time.isoformat()))

        # Get this week's events
        if now.weekday() < 6:
            start_time = datetime(year=now.year, month=now.month, day=now.day + 1, hour=0, minute=0, second=0, tzinfo=self.timezone)
            end_time = start_time + timedelta(days = 6 - now.weekday())
            # We do still want to return events in the next month if they fall within this week. Otherwise
            #if end_time.month != now.month:
            #    end_time = end_time - timedelta(days = end_time.day)
            #    end_time = datetime(year = end_time.year, month = end_time.month, day = end_time.day, hour=23, minute=59, second=59, tzinfo=self.timezone)
            #else:
            end_time = end_time + timedelta(seconds = -1)
            #end_time = datetime(year = end_time.year, month = end_time.month, day = end_time.day - 1, hour=23, minute=59, second=59, tzinfo=self.timezone)
            events.append(self.get_events(start_time.isoformat(), end_time.isoformat()))
        else:
            events.append([])

        # Get this remaining events in the month
        start_time = end_time + timedelta(seconds = 1)
        if start_time.month == now.month:
            if now.month == 12:
                end_time = datetime(year = start_time.year, month = 12, day = 31, hour=23, minute=59, second=59, tzinfo=self.timezone)
            else:
                end_time = datetime(year = start_time.year, month = start_time.month + 1, day = 1, hour=0, minute=0, second=0, tzinfo=self.timezone)
                end_time = end_time - timedelta(seconds = 1)
            events.append(self.get_events(start_time.isoformat(), end_time.isoformat()))
        else:
            events.append([])

        return events
1024837
function decodePeriodTime(map, timeStr, type){
  let times = timeStr.split('/');
  let min = Limit[type][0];
  let max = Limit[type][1];

  let remind = Number(times[0]);
  let period = Number(times[1]);

  if(period==0)
    return;

  for(let i = min; i <= max; i++){
    if(i%period == remind)
      map[i] = i;
  }
}
585406
def to_a
      if @repeat >= 1
        (::Bullshit::Clock::ALL_COLUMNS).map do |t|
          analysis[t].elements
        end.transpose
      else
        []
      end
    end
584765
def p_repeat(self, p):
        ''
        p[0] = Repeat(p[3], p[2], lineno=p.lineno(1))
        p.set_lineno(0, p.lineno(1))
1106580
def handle_rmn_od_on(tokens, options)
      if tokens.size > 3
        month = tokens[2].get_tag(RepeaterMonthName)
        day = tokens[3].get_tag(OrdinalDay).type
        token_range = 0..1
      else
        month = tokens[1].get_tag(RepeaterMonthName)
        day = tokens[2].get_tag(OrdinalDay).type
        token_range = 0..0
      end

      return if month_overflow?(Chronic.now.year, month.index, day)

      handle_m_d(month, day, tokens[token_range], options)
    end