If holiday falls on Saturday or Sunday, use previous Friday instead.
779052
def previous_friday(dt):
    
    if dt.weekday() == 5:
        return dt - timedelta(1)
    elif dt.weekday() == 6:
        return dt - timedelta(2)
    return dt
203310
public WeeklyAutoScalingSchedule withSaturday(java.util.Map<String, String> saturday) {
        setSaturday(saturday);
        return this;
    }
1359962
def iterweekdays(self, d1, d2):
        
        for dt in self.iterdays(d1, d2):
            if not self.isweekend(dt):
                yield dt
914053
static Predicate<DateValue> weekIntervalFilter(
            final int interval, final Weekday wkst, final DateValue dtStart) {
        return new Predicate<DateValue>() {
            DateValue wkStart;

            {
                // the latest day with day of week wkst on or before dtStart
                DTBuilder wkStartB = new DTBuilder(dtStart);
                wkStartB.day -=
                        (7 + Weekday.valueOf(dtStart).javaDayNum - wkst.javaDayNum) % 7;
                wkStart = wkStartB.toDate();
            }

            public boolean apply(DateValue date) {
                int daysBetween = TimeUtils.daysBetween(date, wkStart);
                if (daysBetween < 0) {
                    // date must be before dtStart.  Shouldn't occur in practice.
                    daysBetween += (interval * 7 * (1 + daysBetween / (-7 * interval)));
                }
                int off = (daysBetween / 7) % interval;
                return 0 == off;
            }
        };
    }
622288
def get_next_holiday(self, division=None, date=None):
        
        date = date or datetime.date.today()
        for holiday in self.get_holidays(division=division):
            if holiday['date'] > date:
                return holiday
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
719160
@Override
    public final HolidayCalendar<E> setHolidays(final Set<E> holidays) {

        if (holidays == null) {
            this.holidays = Collections.emptyMap();
            return this;
        }

        final Map<String, E> newSet = new TreeMap<>();
        for (final E e : holidays) {
            newSet.put(toString(e), e);
        }
        this.holidays = Collections.unmodifiableMap(newSet);
        return this;
    }
44665
function isDayBefore(d1, d2) {
  var day1 = clone(d1).setHours(0, 0, 0, 0);
  var day2 = clone(d2).setHours(0, 0, 0, 0);
  return day1 < day2;
}
944961
function() {
            cfg.refireEvent(DEF_CFG.LOCALE_MONTHS.key);
            cfg.refireEvent(DEF_CFG.LOCALE_WEEKDAYS.key);
        }
1082310
private SortedSet<WeekDay> readWeekDays(JSONValue val) {

        JSONArray array = null == val ? null : val.isArray();
        if (null != array) {
            SortedSet<WeekDay> result = new TreeSet<>();
            for (int i = 0; i < array.size(); i++) {
                try {
                    result.add(readWeekDay(array.get(i)));
                } catch (@SuppressWarnings("unused") IllegalArgumentException e) {
                    // Just skip
                }
            }
            return result;
        }
        return new TreeSet<>();
    }
44637
function makeHoliday(date, info, observedInfo) {

  // always make the holiday.
  var holiday = {
    info: info,
    date: {
      month: date.getMonth(),
      day  : date.getDate()
    }
  }

  // if the holiday info's `bank` value has a function then
  // give it the date so it can evaluate the value.
  if ('function' === typeof info.bank) {
    info.bank = info.bank(date)
  }

  // without an observed holiday we return only the main holiday
  if (date.observed == null) {
    return holiday
  }

  // there's an observed date so return both holidays in an array.
  else {
    return [
      holiday, // main holiday
      {        // observed holiday
        info: observedInfo,
        date: {
          month: date.observed.getMonth(),
          day  : date.observed.getDate()
        }
      }
    ]
  }
}
520770
def previous_weekday(date):
    '''
    
    '''
    weekday = date.weekday()
    if weekday == 0:
        n_days = 3
    elif weekday == 6:
        n_days = 2
    else:
        n_days = 1
    return date - datetime.timedelta(days=n_days)
1077859
void formatWeekday(StringBuilder b, ZonedDateTime d, int width, FieldVariants weekdays) {
    int weekday = d.getDayOfWeek().getValue() % 7;
    switch (width) {
      case 6:
        b.append(weekdays.short_[weekday]);
        break;

      case 5:
        b.append(weekdays.narrow[weekday]);
        break;

      case 4:
        b.append(weekdays.wide[weekday]);
        break;

      case 3:
      case 2:
      case 1:
        b.append(weekdays.abbreviated[weekday]);
        break;
    }
  }
1209365
@Nonnegative
  public static DayOfWeek getWeekday (@Nonnull final Weekday eWeekday)
  {
    switch (eWeekday)
    {
      case MONDAY:
        return DayOfWeek.MONDAY;
      case TUESDAY:
        return DayOfWeek.TUESDAY;
      case WEDNESDAY:
        return DayOfWeek.WEDNESDAY;
      case THURSDAY:
        return DayOfWeek.THURSDAY;
      case FRIDAY:
        return DayOfWeek.FRIDAY;
      case SATURDAY:
        return DayOfWeek.SATURDAY;
      case SUNDAY:
        return DayOfWeek.SUNDAY;
      default:
        throw new IllegalArgumentException ("Unknown weekday " + eWeekday);
    }
  }
316659
function expand( day ) {
  switch ( day ) {
  case 'weekend':
  case 'weekday':
    return _( days ).pickBy( value => value.type === day ).keys();
  default:
    return [ day ];
  }
}
24038
def weekday_yesterday(self, date_from=None, date_format=None):
		
		# date d'hier que sur les jours de semaine
		return self.delta(days=-1, date_from=date_from, date_format=date_format, days_range=[1, 2, 3, 4, 5])
1070589
def next_monday_or_tuesday(dt):
    
    dow = dt.weekday()
    if dow == 5 or dow == 6:
        return dt + timedelta(2)
    elif dow == 0:
        return dt + timedelta(1)
    return dt