示例#1
0
 def DateCivile_(self, paques, annee):  # TEST
     """Calcule la date civile en fonction du premier dimanche après Noël."""
     if officia.dimancheapres(datetime.date(annee, 12,
                                            25)) == datetime.date(
                                                annee + 1, 1, 1):
         self._priorite = 0
     return officia.dimancheapres(datetime.date(annee, 12, 25))
示例#2
0
 def DateCivile_(self, paques, annee):  # TEST
     """Calcule la date par rapport à Pâques et au premier dimanche après l'Epiphanie."""
     septuagesime = paques - datetime.timedelta(63)
     retour = officia.dimancheapres(datetime.date(
         annee, 1, 6)) + datetime.timedelta(self.date_)
     if retour > septuagesime:
         retour = septuagesime
         self._priorite = 0
         self.commemoraison_privilegiee = -1
     return retour
示例#3
0
    def DateCivile_(self, paques, annee):  # TEST
        """Une fonction calculant la date civile."""
        date_fixe = datetime.date(annee, self.date_['mois'],
                                  self.date_['jour'])

        if date_fixe.weekday() == 6:  # if it is already a sunday
            return date_fixe

        if self.apres:
            return officia.dimancheapres(date_fixe) + datetime.timedelta(
                self.ecart_dimanche * 7)
        else:
            return officia.dimancheavant(date_fixe) - datetime.timedelta(
                self.ecart_dimanche * 7)
示例#4
0
def test_dimancheapres():
    for i in range(1, 30):
        baseday = datetime.date(1900, 1, i)
        supposed_sunday = dimancheapres(baseday)
        assert supposed_sunday > baseday and supposed_sunday.weekday(
        ) == 6 and supposed_sunday - baseday <= datetime.timedelta(7)
示例#5
0
    def _move(self, new_comer, date):  #TEST
        """Move 'new_comer' if necessary, and put it at the right date.
        new_comer: a Fete class ;
        date: a datetime.date ;
        """
        easter = self.easter(date.year)
        if date.year in self.year_names:
            liste = self.year_data[date.year][date]
        elif date.year in self.previous_year_names:
            liste = self.previous_year_data[date.year][date]
        else:
            if date.year not in self.next_year_names:
                self.next_year_names.append(date.year)
                self.next_year_data[date.year] = self.create_empty_year(
                    date.year)
            liste = self.next_year_data[date.year][date]

        if liste == []:
            liste.append(new_comer)
            return

        #Faut-il déplacer ?
        opponent = liste[0]

        # Case of a new_comer.pal == True -> Pro Aliquibus Locis
        if new_comer.pal:  # NOT TESTED
            liste.append(new_comer)
        # Cas de 'new_comer' ayant la même self.personne que 'opponent'
        elif new_comer.personne.intersection(opponent.personne):
            liste.append(new_comer)
        # Cas de 'new_comer' et 'opponent' tous deux transférés
        elif new_comer.transferee and opponent.transferee:
            if new_comer.priorite > opponent.priorite:
                liste[0] = new_comer
                opponent.transferee = True
                self._move(opponent, date + datetime.timedelta(1))
            else:
                new_comer.date = new_comer.date + datetime.timedelta(1)
                self._move(new_comer, date + datetime.timedelta(1))
        # Si l'un ou l'autre est transféré
        elif new_comer.transferee and opponent.priorite > 800:
            new_comer.date = new_comer.date + datetime.timedelta(1)
            self._move(new_comer, date + datetime.timedelta(1))
        elif opponent.transferee and new_comer.priorite > 800:
            liste[0] = new_comer
            opponent.date = opponent.date + datetime.timedelta(1)
            self._move(opponent, date + datetime.timedelta(1))
        # Cas de 'new_comer' fête de première classe vs 'opponent' fête de première classe
        elif new_comer.priorite > 1600:
            if new_comer.priorite < opponent.priorite and not new_comer.dimanche:
                new_comer.transferee = True
                self._move(new_comer, date + datetime.timedelta(1))
            elif opponent.priorite > 1600 and opponent.priorite < new_comer.priorite and not opponent.dimanche:
                liste[0] = new_comer
                opponent.transferee = True
                self._move(opponent, date + datetime.timedelta(1))
            else:
                liste.append(new_comer)
        elif self.proper != 'roman' and (new_comer.occurrence_perpetuelle
                                         or opponent.occurrence_perpetuelle):
            premier_dimanche_avent = officia.dimancheapres(
                datetime.date(date.year, 12, 25)) - datetime.timedelta(28)
            # Cas de 'new_comer' fête de seconde classe empêchée perpétuellement # WARNING pourquoi la valeur self.transferee n'est-elle pas modifiée en-dessous ? WARNING
            if new_comer.priorite > 800 and opponent.priorite > 800 and opponent.priorite > new_comer.priorite and not new_comer.dimanche:
                new_comer.date = new_comer.date + datetime.timedelta(1)
                self._move(new_comer, date + datetime.timedelta(1))
            elif opponent.priorite > 800 and new_comer.priorite > 800 and new_comer.priorite > opponent.priorite and not opponent.dimanche:
                liste[0] = new_comer
                opponent.date = opponent.date + datetime.timedelta(1)
                self._move(opponent, date + datetime.timedelta(1))
            # Cas de 'new_comer' fête de troisième classe particulière empêchée perpétuellement
            elif not date - easter >= datetime.timedelta(
                    -46) and not date - easter < datetime.timedelta(
                        0) and not new_comer.date < datetime.date(
                            date.year, 12, 25
                        ) and not new_comer.date >= premier_dimanche_avent:
                if new_comer.priorite <= 700 and new_comer.priorite >= 550 and new_comer.priorite < opponent.priorite and not new_comer.dimanche:
                    new_comer.date = new_comer.date + datetime.timedelta(1)
                    self._move(new_comer, date + datetime.timedelta(1))
                elif opponent.priorite <= 700 and new_comer.priorite >= 550 and new_comer.priorite > opponent.priorite and not opponent.dimanche:
                    liste[0] = new_comer
                    opponent.date = opponent.date + datetime.timedelta(1)
                    self._move(opponent, date + datetime.timedelta(1))
                else:
                    liste.append(new_comer)
            else:
                liste.append(new_comer)
        else:
            liste.append(new_comer)
        liste.sort(key=lambda x: x.priorite, reverse=True)