Renamed the method _get_month_text() to _month_text(), _get_year_text() to _year_text(), and _get_date_text() to _date_text() in Period.Parser in the Mia core application.

This commit is contained in:
依瑪貓 2020-08-03 21:28:35 +08:00
parent 7b92ff7567
commit 4cd0f0636d

View File

@ -437,7 +437,7 @@ class Period:
self.invalid_period()
return
self.end = self.get_month_last_day(self.start)
self.description = self._get_month_text(year, month)
self.description = self._month_text(year, month)
return
# From a specific month
m = re.match("^([0-9]{4})-([0-9]{2})-$", spec)
@ -451,8 +451,8 @@ class Period:
return
self.end = self.get_month_last_day(
timezone.localdate())
self.description = gettext(
"Since %s") % self._get_month_text(year, month)
self.description = gettext("Since %s")\
% self._month_text(year, month)
return
# Until a specific month
m = re.match("^-([0-9]{4})-([0-9]{2})$", spec)
@ -466,8 +466,8 @@ class Period:
return
self.start = datetime.date(2000, 1, 1)
self.end = self.get_month_last_day(until_month)
self.description = gettext(
"Until %s") % self._get_month_text(year, month)
self.description = gettext("Until %s")\
% self._month_text(year, month)
return
# A specific year
m = re.match("^([0-9]{4})$", spec)
@ -479,7 +479,7 @@ class Period:
self.invalid_period()
return
self.end = datetime.date(year, 12, 31)
self.description = self._get_year_text(year)
self.description = self._year_text(year)
return
# Until a specific year
m = re.match("^-([0-9]{4})$", spec)
@ -491,8 +491,8 @@ class Period:
self.invalid_period()
return
self.start = datetime.date(2000, 1, 1)
self.description = gettext(
"Until %s") % self._get_year_text(year)
self.description = gettext("Until %s")\
% self._year_text(year)
return
# All time
if spec == "-":
@ -514,7 +514,7 @@ class Period:
self.invalid_period()
return
self.end = self.start
self.description = self._get_date_text(self.start)
self.description = self._date_text(self.start)
return
# A specific date period
m = re.match(("^([0-9]{4})-([0-9]{2})-([0-9]{2})"
@ -562,7 +562,7 @@ class Period:
# At the same day
else:
self.spec = dateformat.format(self.start, "Y-m-d")
self.description = self._get_date_text(self.start)
self.description = self._date_text(self.start)
return
# Until a specific day
m = re.match("^-([0-9]{4})-([0-9]{2})-([0-9]{2})$", spec)
@ -576,8 +576,8 @@ class Period:
self.invalid_period()
return
self.start = datetime.date(2000, 1, 1)
self.description = gettext(
"Until %s") % self._get_date_text(self.end)
self.description = gettext("Until %s")\
% self._date_text(self.end)
return
# Wrong period format
self.invalid_period()
@ -616,7 +616,7 @@ class Period:
next_year, next_month, 1) - datetime.timedelta(days=1)
@staticmethod
def _get_month_text(year, month):
def _month_text(year, month):
"""Returns the text description of a month.
Args:
@ -640,7 +640,7 @@ class Period:
return "%d/%d" % (year, month)
@staticmethod
def _get_year_text(year):
def _year_text(year):
"""Returns the text description of a year.
Args:
@ -657,7 +657,7 @@ class Period:
return str(year)
@staticmethod
def _get_date_text(day):
def _date_text(day):
"""Returns the text description of a day.
Args: