def check_monthday(dt): result = self.monthdays is None or dt.day in self.monthdays if self.monthdays: self._log_debug(DEBUG_CHECK_MONTH_DAY, state_str(result), dt.day, "" if result else "not ", set_str(self.monthdays)) return result
def __str__(self): s = "Period \"{}\": ".format(self.name) conditions = [] if self.begintime: conditions.append("starts at {}".format(time_str(self.begintime))) if self.endtime: conditions.append("ends at {}".format(time_str(self.endtime))) if self.weekdays is not None: conditions.append("on weekdays ({})".format(set_str(self.weekdays, configuration.WEEKDAY_NAMES))) if self.monthdays: conditions.append("on monthdays ({})".format(set_str(self.monthdays))) if self.months: conditions.append("in months ({})".format(set_str(self.months, configuration.MONTH_NAMES, offset=1))) s += ", ".join(conditions) return s
def check_weekday(dt): result = self.weekdays is None or dt.weekday() in self.weekdays if self.weekdays is not None: self._log_debug( DEBUG_CHECK_WEEKDAYS, state_str(result), configuration.WEEKDAY_NAMES[dt.weekday()], not_str(result), set_str(self.weekdays, displaynames=configuration.WEEKDAY_NAMES)) return result
def check_month(dt): result = self.months is None or dt.month in self.months if self.months: self._log_debug( DEBUG_CHECK_MONTH, state_str(result), configuration.MONTH_NAMES[dt.month - 1], not_str(result), set_str(self.months, displaynames=configuration.MONTH_NAMES, offset=1)) return result