• Jérome Perrin's avatar
    periodicity: fix infinite loop with impossible combinations of week and months · 1b487f8c
    Jérome Perrin authored
    Some combinations of periodicity, for example repeat every first week
    of the year and every month February are impossible (because the first
    week of the year is always in January) and such configurations caused
    infinite loops or probably overflow if we wait long enough.
    
    The algorithm being to try the next day until all constraints are met,
    it is not guaranteed to terminate.
    
    To make sure the algorithm terminate, we rely on the fact that calendars
    repeat after some time, so if after a few years we did not find a
    matching combination, we can stop retrying.
    
    according to https://en.wikipedia.org/wiki/Determination_of_the_day_of_the_week
    
    > Each leap year repeats once every 28 years, and every common year
    > repeats once every 6 years and twice every 11 years.
    
    so trying for 28 years should be enough to see all combinations
    1b487f8c
document.erp5.PresencePeriod.py 7.88 KB