From 12c93ff9dae9703e15e51811daa980b88b9a4216 Mon Sep 17 00:00:00 2001 From: korenstin Date: Tue, 30 Jul 2024 02:52:11 +0200 Subject: [PATCH] bug du jour 31 juillet (bissextile) --- apps/member/models.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/member/models.py b/apps/member/models.py index 4f78ecd3..dcbafb8d 100644 --- a/apps/member/models.py +++ b/apps/member/models.py @@ -295,7 +295,14 @@ class Club(models.Model): today = datetime.date.today() - while (today - self.membership_start).days >= 365: + # Avoid any problems on February 29 + if self.membership_start.month == 2 and self.membership_start.day == 29: + self.membership_start -= datetime.timedelta(days=1) + if self.membership_end.month == 2 and self.membership_end.day == 29: + self.membership_end += datetime.timedelta(days=1) + + while today >= datetime.date(self.membership_start.year + 1, + self.membership_start.month, self.membership_start.day): if self.membership_start: self.membership_start = datetime.date(self.membership_start.year + 1, self.membership_start.month, self.membership_start.day)