From 95cd08a887d74e493e1b81d9e29329a61aa836e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Mon, 3 Aug 2020 21:35:25 +0800 Subject: [PATCH] Added the VERY_START constant in Period.Parser to denote the earliest-possible beginning in the Mia core application. --- mia_core/period.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/mia_core/period.py b/mia_core/period.py index e6287ca..a6d0e01 100644 --- a/mia_core/period.py +++ b/mia_core/period.py @@ -415,6 +415,8 @@ class Period: error (str): The period specification format error, or None on success. """ + VERY_START = datetime.date(1990, 1, 1) + def __init__(self, spec): self.spec = None self.start = None @@ -463,7 +465,7 @@ class Period: except ValueError: self.invalid_period() return - self.start = datetime.date(2000, 1, 1) + self.start = Period.Parser.VERY_START self.end = self._month_last_day(until_month) self.description = gettext("Until %s")\ % self._month_text(year, month) @@ -489,13 +491,13 @@ class Period: except ValueError: self.invalid_period() return - self.start = datetime.date(2000, 1, 1) + self.start = Period.Parser.VERY_START self.description = gettext("Until %s")\ % self._year_text(year) return # All time if spec == "-": - self.start = datetime.date(2000, 1, 1) + self.start = Period.Parser.VERY_START self.end = self._month_last_day(timezone.localdate()) self.description = gettext("All") return @@ -573,7 +575,7 @@ class Period: except ValueError: self.invalid_period() return - self.start = datetime.date(2000, 1, 1) + self.start = Period.Parser.VERY_START self.description = gettext("Until %s")\ % self._date_text(self.end) return