Revised to simplify the YearPeriod period.

This commit is contained in:
依瑪貓 2023-03-09 18:03:02 +08:00
parent b4be1db712
commit ef086b3f81

View File

@ -553,6 +553,7 @@ class TemplatePeriod(Period):
class YearPeriod(Period): class YearPeriod(Period):
"""A year period.""" """A year period."""
def __init__(self, year: int): def __init__(self, year: int):
"""Constructs a year period. """Constructs a year period.
@ -561,8 +562,6 @@ class YearPeriod(Period):
start: datetime.date = datetime.date(year, 1, 1) start: datetime.date = datetime.date(year, 1, 1)
end: datetime.date = datetime.date(year, 12, 31) end: datetime.date = datetime.date(year, 12, 31)
super().__init__(start, end) super().__init__(start, end)
self.spec = str(year)
self.is_a_year = True
DATE_SPEC_RE: str = r"(\d{4})(?:-(\d{2})(?:-(\d{2}))?)?" DATE_SPEC_RE: str = r"(\d{4})(?:-(\d{2})(?:-(\d{2}))?)?"