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