diff options
author | Matthew Lemon <matt@matthewlemon.com> | 2021-05-16 20:49:47 +0100 |
---|---|---|
committer | Matthew Lemon <matt@matthewlemon.com> | 2021-05-16 20:49:47 +0100 |
commit | e3f26229d0f69ddb93b866e184626337c30778c2 (patch) | |
tree | f717215435d45d6bfb5f80bc9db877cb9ed0b90f /datamaps/core/temporal.py | |
parent | a3025ff72dc89a3a26dab359da8f41769bab3b97 (diff) |
changed api for month
Diffstat (limited to 'datamaps/core/temporal.py')
-rw-r--r-- | datamaps/core/temporal.py | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/datamaps/core/temporal.py b/datamaps/core/temporal.py index 23d4b23..24a0d70 100644 --- a/datamaps/core/temporal.py +++ b/datamaps/core/temporal.py @@ -22,22 +22,22 @@ class Month: } def __init__(self, month: int, year: int): - self._month = month + self._month_int = month self.year = year @property def start_date(self): - return datetime.date(self.year, self._month, 1) + return datetime.date(self.year, self._month_int, 1) @property def end_date(self): - if self._month == 2 and calendar.isleap(self.year): - return datetime.date(self.year, self._month, Month._end_ints[self._month] + 1) + if self._month_int == 2 and calendar.isleap(self.year): + return datetime.date(self.year, self._month_int, Month._end_ints[self._month_int] + 1) else: - return datetime.date(self.year, self._month, Month._end_ints[self._month]) + return datetime.date(self.year, self._month_int, Month._end_ints[self._month_int]) @property - def month(self): + def name(self): return [ "January", "February", @@ -51,7 +51,10 @@ class Month: "October", "November", "December", - ][self._month - 1] + ][self._month_int - 1] + + def __repr__(self): + return f"Month({self.name})" class FinancialYear: |