筛选出指定星期[和指定星期几]的课程

    :param curriculum: 课程表数据
    :param week: 需要筛选的周数, 是一个代表周数的正整数
    :param weekday: 星期几, 是一个代表星期的整数, 1-7 对应周一到周日
    :return: 如果 weekday 参数没给出, 返回的格式与原课表一致, 但只包括了在指定周数的课程, 否则返回指定周数和星期几的当天课程
775838
def filter_curriculum(curriculum, week, weekday=None):
    
    if weekday:
        c = [deepcopy(curriculum[weekday - 1])]
    else:
        c = deepcopy(curriculum)
    for d in c:
        l = len(d)
        for t_idx in range(l):
            t = d[t_idx]
            if t is None:
                continue
            # 一般同一时间课程不会重复，重复时给出警告
            t = list(filter(lambda k: week in k['上课周数'], t)) or None
            if t is not None and len(t) > 1:
                logger.warning('第 %d 周周 %d 第 %d 节课有冲突: %s', week, weekday or c.index(d) + 1, t_idx + 1, t)
            d[t_idx] = t
    return c[0] if weekday else c
829722
def get_shifted_holidays(self, dates):
        
        for holiday, label in dates:
            if holiday.weekday() == SUN:
                yield (
                    holiday + timedelta(days=1),
                    label + ' shift'
                )
673575
def _cal_monday(self, day_num):
        
        if self.options['cal_monday'] or not self.options['cal_weekend']:
            day_num -= 1
            if day_num < 0:
                day_num = 6
        return day_num
462645
function getWeekendRange(localeData) {
  const startDay =
    localeData.get(`supplemental/weekData/weekendStart/${localeData.attributes.territory}`) ||
    localeData.get('supplemental/weekData/weekendStart/001');
  const endDay =
    localeData.get(`supplemental/weekData/weekendEnd/${localeData.attributes.territory}`) ||
    localeData.get('supplemental/weekData/weekendEnd/001');
  return [WEEK_DAYS.indexOf(startDay), WEEK_DAYS.indexOf(endDay)];
}
927907
static DateValue nextWeekStart(DateValue d, Weekday wkst) {
        DTBuilder builder = new DTBuilder(d);
        builder.day += (7 - ((7 + (Weekday.valueOf(d).javaDayNum
                - wkst.javaDayNum)) % 7))
                % 7;
        return builder.toDate();
    }
448910
public Set<Weekday> getSet() {

    if (this.set == null) {
      HashSet<Weekday> hashSet = new HashSet<Weekday>();
      int value = getValue().intValue();
      for (Weekday weekday : Weekday.values()) {
        int mask = (1 << weekday.ordinal());
        if ((value & mask) != 0) {
          hashSet.add(weekday);
        }
      }
      this.set = Collections.unmodifiableSet(hashSet);
    }
    return this.set;
  }
203738
public static Calendar beginOfWeek(Calendar calendar, boolean isMondayAsFirstDay) {
		if(isMondayAsFirstDay) {
			calendar.setFirstDayOfWeek(Calendar.MONDAY);
		}
		return truncate(calendar, DateField.WEEK_OF_MONTH);
	}
883323
def next_weekday(weekday):
    """"""
    ix = WEEKDAYS.index(weekday)
    if ix == len(WEEKDAYS)-1:
        return WEEKDAYS[0]
    return WEEKDAYS[ix+1]
1104864
def next_monday(dt):
    
    if dt.weekday() == 5:
        return dt + timedelta(2)
    elif dt.weekday() == 6:
        return dt + timedelta(1)
    return dt
786047
function getWeeks (date) {

                    var weeks = [];
                    var date = moment.utc(date);
                    var firstDayOfMonth = moment(date).date(1);
                    var lastDayOfMonth  = moment(date).date(date.daysInMonth());

                    var startDay = moment(firstDayOfMonth);
                    var endDay   = moment(lastDayOfMonth);
                    // NB: We use weekday() to get a locale aware weekday
                    startDay = firstDayOfMonth.weekday() === 0 ? startDay : startDay.weekday(0);
                    endDay   = lastDayOfMonth.weekday()  === 6 ? endDay   : endDay.weekday(6);

                    var currentWeek = [];

                    for (var start = moment(startDay); start.isBefore(moment(endDay).add(1, 'days')); start.add(1, 'days')) {

                        var afterMinDate  = !scope.config.minDate || start.isAfter(scope.config.minDate, 'day');
                        var beforeMaxDate = !scope.config.maxDate || start.isBefore(scope.config.maxDate, 'day');
                        var isFuture      = start.isAfter(today);
                        var beforeFuture  = scope.config.allowFuture || !isFuture;

                        var day = {
                            date: moment(start).toDate(),
                            isToday: start.isSame(today, 'day'),
                            isInMonth: start.isSame(firstDayOfMonth, 'month'),
                            isSelected: start.isSame(dateSelected, 'day'),
                            isSelectable: afterMinDate && beforeMaxDate && beforeFuture
                        };

                        currentWeek.push(day);

                        if (start.weekday() === 6 || start === endDay) {
                            weeks.push(currentWeek);
                            currentWeek = [];
                        }
                    }

                    return weeks;
                }
1260354
public static DayOfWeek toDayOfWeek(final Calendar self) {
        return DayOfWeek.of(self.get(Calendar.DAY_OF_WEEK)).minus(1);
    }
1020523
protected SortedSet<WeekDay> getWeekDays() {

        SortedSet<WeekDay> result = new TreeSet<>();
        for (CmsCheckBox box : m_checkboxes) {
            if (box.isChecked()) {
                result.add(WeekDay.valueOf(box.getInternalValue()));
            }
        }
        return result;
    }
1076417
private String[] weekdayMap(JsonObject node) {
    String[] res = new String[7];
    for (int i = 0; i < 7; i++) {
      res[i] = node.get(WEEKDAY_KEYS[i]).getAsString();
    }
    return res;
  }
892057
public Weekday getDayOfWeek() {

        long utcDays = getCalendarSystem(this.variant).transform(this);
        return Weekday.valueOf(MathUtils.floorModulo(utcDays + 5, 7) + 1);

    }
793610
def get_next_weekday(self, including_today=False):
        
        weekday = self.date_time.weekday()
        return Weekday.get_next(weekday, including_today=including_today)
116524
public static WeekDay getWeekDay(final Calendar cal) {
        return new WeekDay(getDay(cal.get(Calendar.DAY_OF_WEEK)), 0);
    }
640775
def next_weekday(date):
    '''
    
    '''
    n_days = 7 - date.weekday()
    if n_days > 3:
        n_days = 1
    return date + datetime.timedelta(days=n_days)