Ejemplo n.º 1
0
    def getUntilDate(self):

        if self._cached_until is None:
            year = 9999
            month = 12
            day = 1
            hours = 0
            minutes = 0
            seconds = 0
            mode = None
            if self.until and not self.until.startswith("#"):
                splits = self.until.split(" ")
                year = int(splits[0])
                month = 1
                day = 1
                hours = 0
                minutes = 0
                seconds = 0
                mode = None
                if len(splits) > 1 and not splits[1].startswith("#"):
                    month = int(rule.Rule.MONTH_NAME_TO_POS[splits[1]])
                    if len(splits) > 2 and not splits[2].startswith("#"):
                        if splits[2] == "lastSun":
                            dt = DateTime(year=year, month=month, day=1)
                            dt.setDayOfWeekInMonth(-1, DateTime.SUNDAY)
                            splits[2] = dt.getDay()
                        elif splits[2] == "lastSat":
                            dt = DateTime(year=year, month=month, day=1)
                            dt.setDayOfWeekInMonth(-1, DateTime.SATURDAY)
                            splits[2] = dt.getDay()
                        elif splits[2] == "Sun>=1":
                            dt = DateTime(year=year, month=month, day=1)
                            dt.setNextDayOfWeek(1, DateTime.SUNDAY)
                            splits[2] = dt.getDay()
                        elif splits[2] == "Sun>=8":
                            dt = DateTime(year=year, month=month, day=1)
                            dt.setNextDayOfWeek(8, DateTime.SUNDAY)
                            splits[2] = dt.getDay()
                        day = int(splits[2])
                        if len(splits) > 3 and not splits[3].startswith("#"):
                            splits = splits[3].split(":")
                            hours = int(splits[0])
                            minutes = int(splits[1][:2])
                            if len(splits[1]) > 2:
                                mode = splits[1][2:]
                            else:
                                mode = None
                            if len(splits) > 2:
                                seconds = int(splits[2])

            dt = DateTime(year=year,
                          month=month,
                          day=day,
                          hours=hours,
                          minutes=minutes,
                          seconds=seconds)
            self._cached_until = utils.DateTime(dt, mode)
        return self._cached_until
Ejemplo n.º 2
0
    def fullExpand(self, maxYear):
        """
        Do a full recurrence expansion for each year in the Rule's range, up to
        a specified maximum.

        @param maxYear: maximum year to expand to
        @type maxYear: C{int}
        """
        if self.dt_cache is None:
            start = self.startYear()
            end = self.endYear()
            if end > maxYear:
                end = maxYear - 1
            self.dt_cache = []
            for year in xrange(start, end + 1):
                dt = utils.DateTime(*self.datetimeForYear(year))
                self.dt_cache.append(dt)