Finds next weekday
492405
def next_week_day(base_date, weekday):
    
    day_of_week = base_date.weekday()
    end_of_this_week = base_date + timedelta(days=6 - day_of_week)
    day = end_of_this_week + timedelta(days=1)
    while day.weekday() != weekday:
        day = day + timedelta(days=1)
    return day
624890
private WeekDay readWeekDay(JSONValue val) throws IllegalArgumentException {

        String str = readOptionalString(val);
        if (null != str) {
            return WeekDay.valueOf(str);
        }
        throw new IllegalArgumentException();
    }
1167872
def iso_day_to_weekday(d):
    
    if int(d) == utils.get_now().isoweekday():
        return _("today")
    for w in WEEKDAYS:
        if w[0] == int(d):
            return w[1]
1053452
def next_weekday_in(weekday_abbreviation, direction, count, distance)
      count = direction.downcase == 'b' ? -count.to_i : count.to_i
      weekday = WEEKDAYS[weekday_abbreviation.downcase]

      case distance.downcase
      when "d"
      when "w"
        (@now + count * 7) + weekday[0] - @now.wday  
      when "m"
        future = @now >> count
        future + weekday[0] - future.wday
      when "y"
        future = @now >> count * 12
        future + weekday[0] - future.wday
      end
    end
952797
def next_non_holiday_weekday(holidays, dt):
    
    day_of_week = dt.weekday()

    if day_of_week == SUNDAY:
        while is_holiday_or_weekend(holidays, dt):
            dt += timedelta(1)

    return dt
1172754
private SortedSet<WeekDay> readWeekDays(JSONObject val) {

        try {
            JSONArray array = val.getJSONArray(JsonKey.PATTERN_WEEKDAYS);
            if (null != array) {
                SortedSet<WeekDay> result = new TreeSet<>();
                for (int i = 0; i < array.length(); i++) {
                    try {
                        result.add(WeekDay.valueOf(array.getString(i)));
                    } catch (JSONException | IllegalArgumentException e) {
                        LOG.error("Could not read weekday from JSON. Skipping that day.", e);
                    }
                }
                return result;
            }
        } catch (JSONException e) {
            LOG.debug("Could not read weekdays from JSON", e);
        }
        return new TreeSet<>();

    }
673797
public Weekday getDayOfWeek() {

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

    }
377723
def pickNthWeekday(year, month, dayofweek, hour, minute, whichweek):
    """"""
    first = datetime.datetime(year=year, month=month, hour=hour, minute=minute,
                              day=1)
    weekdayone = first.replace(day=((dayofweek - first.isoweekday()) % 7 + 1))
    for n in xrange(whichweek - 1, -1, -1):
        dt = weekdayone + n * WEEKS
        if dt.month == month:
            return dt
1157830
public static int getCalendarDay(final WeekDay weekday) {
        int calendarDay = -1;
        if (SU.getDay().equals(weekday.getDay())) {
            calendarDay = Calendar.SUNDAY;
        }
        else if (MO.getDay().equals(weekday.getDay())) {
            calendarDay = Calendar.MONDAY;
        }
        else if (TU.getDay().equals(weekday.getDay())) {
            calendarDay = Calendar.TUESDAY;
        }
        else if (WE.getDay().equals(weekday.getDay())) {
            calendarDay = Calendar.WEDNESDAY;
        }
        else if (TH.getDay().equals(weekday.getDay())) {
            calendarDay = Calendar.THURSDAY;
        }
        else if (FR.getDay().equals(weekday.getDay())) {
            calendarDay = Calendar.FRIDAY;
        }
        else if (SA.getDay().equals(weekday.getDay())) {
            calendarDay = Calendar.SATURDAY;
        }
        return calendarDay;
    }
318097
def get_next(weekday, including_today=False):
        
        now = datetime.datetime.now()
        if now.weekday() == weekday.value and including_today:
            delta = datetime.timedelta(days=0)
        elif now.weekday() == weekday.value and not including_today:
            delta = datetime.timedelta(days=7)
        else:
            delta = datetime.timedelta(
                (7 + weekday.value - now.weekday()) % 7
            )  # times delta to next instance
        return Day(now + delta).get_just_date()
618838
def get_next(self):
        """"""
        return BillingCycle.objects.filter(date_range__gt=self.date_range).order_by('date_range').first()
573594
def weekly(date=datetime.date.today()):
    
    return date - datetime.timedelta(days=date.weekday())
1137882
function(weekBeginDate) {
        var overlaps = false;
        var nextWeek = this.add(weekBeginDate, this.DAY, 6);
        if (nextWeek.getFullYear() != weekBeginDate.getFullYear()) {
            overlaps = true;
        }
        return overlaps;
    }
1196503
def next_working_day(count = 1)
      return self if count == 0
      negative = count < 0
      count = count.abs
      date = negative ? yesterday : tomorrow
      
      loop do
        count -= 1 if date.working_day?
        return date if count.zero? 
        
        date += (negative ? -1 : 1).day
      end
    end
1065352
def this_week():
        
        since = TODAY + delta(weekday=MONDAY(-1))
        until = since + delta(weeks=1)
        return Date(since), Date(until)
949437
def handle_friday(next_date: Datum, period: str, mult: int, start_date: Datum):
    
    assert isinstance(next_date, Datum)
    assert isinstance(start_date, Datum)

    # Starting from line 220.
    tmp_sat = next_date.clone()
    tmp_sat.add_days(1)

    tmp_sun = next_date.clone()
    tmp_sun.add_days(2)

    if period == RecurrencePeriod.END_OF_MONTH.value:
        if (next_date.is_end_of_month() or tmp_sat.is_end_of_month() or
                tmp_sun.is_end_of_month()):
            next_date.add_months(1)
        else:
            next_date.add_months(mult - 1)
    else:
        if tmp_sat.get_day_name() == start_date.get_day_name():
            next_date.add_days(1)
            next_date.add_months(mult)
        elif tmp_sun.get_day_name() == start_date.get_day_name():
            next_date.add_days(2)
            next_date.add_months(mult)
        elif next_date.get_day() >= start_date.get_day():
            next_date.add_months(mult)
        elif next_date.is_end_of_month():
            next_date.add_months(mult)
        elif tmp_sat.is_end_of_month():
            next_date.add_days(1)
            next_date.add_months(mult)
        elif tmp_sun.is_end_of_month():
            next_date.add_days(2)
            next_date.add_months(mult)
        else:
            # /* one fewer month fwd because of the occurrence in this month */
            next_date.subtract_months(1)

    return next_date
268411
def get_next_scheduled_time(cron_string):
    """"""
    itr = croniter.croniter(cron_string, datetime.utcnow())
    return itr.get_next(datetime)