def _get_weekday()

in source/lambda/configuration/setbuilders/monthday_setbuilder.py [0:0]


    def _get_weekday(self, day_str):
        # returns working day nearest to day in month, string is in format dayW
        if (1 < len(day_str) <= 3) and day_str.endswith(self.WILDCARD_WEEKDAY):
            day = self._get_value_by_str(day_str[0:-1])
            if day is not None:
                # calculated day of week based on first weekday of month
                weekday = ((day % 7) + self._firstweekday - 1) % 7
                # for Saturdays use Friday, or Monday if it is the first day of the month
                if weekday == 5:
                    day = day - 1 if day > 1 else day + 2
                # for Sundays use next Monday, or Saturday if it is the last day of the month
                elif weekday == 6:
                    day = day + 1 if day < self._lastday else day - 2
                # for other days just return the specified day
                return [day]

        return None