Removed unnecessary @property decorations in the Period utility in the Mia core application.

This commit is contained in:
依瑪貓 2020-08-02 02:27:54 +08:00
parent 783ecea5cb
commit c3fc7ad3ca

View File

@ -118,7 +118,6 @@ class Period:
year = year + 1 year = year + 1
return datetime.date(year, month, 1) return datetime.date(year, month, 1)
@property
def this_month(self): def this_month(self):
"""Returns the specification of this month. """Returns the specification of this month.
@ -135,7 +134,6 @@ class Period:
return None return None
return dateformat.format(today, "Y-m") return dateformat.format(today, "Y-m")
@property
def last_month(self): def last_month(self):
"""Returns the specification of last month. """Returns the specification of last month.
@ -152,7 +150,6 @@ class Period:
return None return None
return dateformat.format(last_month_start, "Y-m") return dateformat.format(last_month_start, "Y-m")
@property
def since_last_month(self): def since_last_month(self):
"""Returns the specification since last month. """Returns the specification since last month.
@ -160,12 +157,11 @@ class Period:
str|None: The specification since last month, or None if there is str|None: The specification since last month, or None if there is
no data in or before last month. no data in or before last month.
""" """
last_month = self.last_month last_month = self.last_month()
if last_month is None: if last_month is None:
return None return None
return self.last_month + "-" return last_month + "-"
@property
def has_months_to_choose(self): def has_months_to_choose(self):
"""Returns whether there are months to choose besides this month and """Returns whether there are months to choose besides this month and
last month. last month.
@ -182,7 +178,6 @@ class Period:
return True return True
return False return False
@property
def chosen_month(self): def chosen_month(self):
"""Returns the specification of the chosen month, or None if the """Returns the specification of the chosen month, or None if the
current period is not a month or is out of available data range. current period is not a month or is out of available data range.
@ -203,7 +198,6 @@ class Period:
return None return None
return self._period.spec return self._period.spec
@property
def this_year(self): def this_year(self):
"""Returns the specification of this year. """Returns the specification of this year.
@ -218,7 +212,6 @@ class Period:
return None return None
return str(this_year) return str(this_year)
@property
def last_year(self): def last_year(self):
"""Returns the specification of last year. """Returns the specification of last year.
@ -233,7 +226,6 @@ class Period:
return None return None
return str(last_year) return str(last_year)
@property
def has_years_to_choose(self): def has_years_to_choose(self):
"""Returns whether there are years to choose besides this year and """Returns whether there are years to choose besides this year and
last year. last year.
@ -251,7 +243,6 @@ class Period:
return True return True
return False return False
@property
def years_to_choose(self): def years_to_choose(self):
"""Returns the years to choose besides this year and last year. """Returns the years to choose besides this year and last year.
@ -280,7 +271,6 @@ class Period:
if self._period.spec == str(year): if self._period.spec == str(year):
return True return True
@property
def today(self): def today(self):
"""Returns the specification of today. """Returns the specification of today.
@ -295,7 +285,6 @@ class Period:
return None return None
return dateformat.format(today, "Y-m-d") return dateformat.format(today, "Y-m-d")
@property
def yesterday(self): def yesterday(self):
"""Returns the specification of yesterday. """Returns the specification of yesterday.
@ -310,7 +299,6 @@ class Period:
return None return None
return dateformat.format(yesterday, "Y-m-d") return dateformat.format(yesterday, "Y-m-d")
@property
def chosen_day(self): def chosen_day(self):
"""Returns the specification of the chosen day. """Returns the specification of the chosen day.
@ -320,7 +308,6 @@ class Period:
""" """
return dateformat.format(self._period.start, "Y-m-d") return dateformat.format(self._period.start, "Y-m-d")
@property
def has_days_to_choose(self): def has_days_to_choose(self):
"""Returns whether there are more than one day to choose from. """Returns whether there are more than one day to choose from.
@ -334,7 +321,6 @@ class Period:
return False return False
return True return True
@property
def first_day(self): def first_day(self):
"""Returns the specification of the available first day. """Returns the specification of the available first day.
@ -345,7 +331,6 @@ class Period:
return None return None
return dateformat.format(self._data_start, "Y-m-d") return dateformat.format(self._data_start, "Y-m-d")
@property
def last_day(self): def last_day(self):
"""Returns the specification of the available last day. """Returns the specification of the available last day.
@ -356,7 +341,6 @@ class Period:
return None return None
return dateformat.format(self._data_end, "Y-m-d") return dateformat.format(self._data_end, "Y-m-d")
@property
def chosen_start(self): def chosen_start(self):
"""Returns the specification of of the first day of the """Returns the specification of of the first day of the
specified period. specified period.
@ -372,7 +356,6 @@ class Period:
else self._data_start else self._data_start
return dateformat.format(day, "Y-m-d") return dateformat.format(day, "Y-m-d")
@property
def chosen_end(self): def chosen_end(self):
"""Returns the specification of of the last day of the """Returns the specification of of the last day of the
specified period. specified period.
@ -388,7 +371,6 @@ class Period:
else self._data_end else self._data_end
return dateformat.format(day, "Y-m-d") return dateformat.format(day, "Y-m-d")
@property
def month_picker_params(self): def month_picker_params(self):
"""Returns the parameters for the month-picker, as a JSON text string. """Returns the parameters for the month-picker, as a JSON text string.
@ -402,7 +384,7 @@ class Period:
"locale": Language.current().locale, "locale": Language.current().locale,
"minDate": start, "minDate": start,
"maxDate": self._data_end, "maxDate": self._data_end,
"defaultDate": self.chosen_month, "defaultDate": self.chosen_month(),
}) })
@staticmethod @staticmethod