Added the __format_day method to the PeriodDescription utility to simplify the code.
This commit is contained in:
parent
4eebbd9692
commit
7ddc9ececf
@ -340,9 +340,7 @@ class PeriodDescription:
|
||||
:return: The description as a day range.
|
||||
:raise ValueError: The period is a month or year range.
|
||||
"""
|
||||
start: str = "{year}/{month}/{day}".format(
|
||||
year=self.__start.year, month=self.__start.month,
|
||||
day=self.__start.day)
|
||||
start: str = self.__format_day(self.__start)
|
||||
if self.__start == self.__end:
|
||||
return gettext("in %(period)s", period=start)
|
||||
if self.__start.year == self.__end.year \
|
||||
@ -374,6 +372,15 @@ class PeriodDescription:
|
||||
"""
|
||||
return f"{month.year}/{month.month}"
|
||||
|
||||
@staticmethod
|
||||
def __format_day(day: datetime.date) -> str:
|
||||
"""Formats a day.
|
||||
|
||||
:param day: The day.
|
||||
:return: The formatted day.
|
||||
"""
|
||||
return f"{day.year}/{day.month}/{day.day}"
|
||||
|
||||
|
||||
class ThisMonth(Period):
|
||||
"""The period of this month."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user