8413: Finnish Date format settings does nothing

The corresponding fi.po, with month inflections, is from:
Matti Niemelä <matti.u.niemela@gmail.com>
This commit is contained in:
Paul Franklin 2015-05-15 00:37:37 -07:00
parent d7719962fd
commit 578cdf6c79

View File

@ -98,7 +98,8 @@ class DateParserFI(DateParser):
def init_strings(self): def init_strings(self):
DateParser.init_strings(self) DateParser.init_strings(self)
# date, whitespace self._text2 = re.compile('(\d+)?\.?\s+?%s\.?\s*((\d+)(/\d+)?)?\s*$'
% self._mon_str, re.IGNORECASE)
self._span = re.compile("(?P<start>.+)\s+(-)\s+(?P<stop>.+)", self._span = re.compile("(?P<start>.+)\s+(-)\s+(?P<stop>.+)",
re.IGNORECASE) re.IGNORECASE)
self._range = re.compile( self._range = re.compile(
@ -114,90 +115,68 @@ class DateDisplayFI(DateDisplay):
""" """
Finnish language date display class. Finnish language date display class.
""" """
long_months = ("", "Tammikuu", "Helmikuu", "Maaliskuu", "Huhtikuu",
"Toukokuu", "Kesäkuu", "Heinäkuu", "Elokuu",
"Syyskuu", "Lokakuu", "Marraskuu", "Joulukuu")
short_months = ("", "Tammi", "Helmi", "Maali", "Huhti", "Touko",
"Kesäk", "Heinä", "Eloku", "Syysk", "Lokak", "Marra",
"Joulu")
calendar = ("",
"juliaaninen",
"heprealainen",
"ranskan v.",
"persialainen",
"islamilainen",
"svensk"
)
_qual_str = ("", "arviolta", "laskettuna")
_bce_str = "%s ekr." _bce_str = "%s ekr."
formats = ( formats = (
"VVVV-KK-PP (ISO)", "VVVV-KK-PP (ISO)",
"PP.KK.VVVV" "PP.KK.VVVV",
"Päivä Kuukausi Vuosi" # Day, full month name, year
) )
# normally, this would agree with DateDisplayEn's "formats" # this definition must agree with its "_display_calendar" method
# (since no locale-specific _display_gregorian exists, here),
# but the locale-specific "display" (below) forces self.format = 1
def display(self, date): display = DateDisplay.display_formatted
"""
Return a text string representing the date.
"""
mod = date.get_modifier()
qual = date.get_quality()
cal = date.get_calendar()
start = date.get_start_date()
newyear = date.get_new_year()
if mod == Date.MOD_TEXTONLY:
return date.get_text()
if start == Date.EMPTY:
return ""
# select numerical date format def _display_calendar(self, date_val, long_months, short_months = None,
self.format = 1 inflect=""):
# this must agree with its locale-specific "formats" definition
if mod == Date.MOD_SPAN: if short_months is None:
d1 = self.display_cal[cal](start) # Let the short formats work the same as long formats
d2 = self.display_cal[cal](date.get_stop_date()) short_months = long_months
text = "%s - %s" % (d1, d2)
elif mod == Date.MOD_RANGE: if self.format == 0:
stop = date.get_stop_date() return self.display_iso(date_val)
if start[0] == start[1] == 0 and stop[0] == 0 and stop[1] == 0: elif self.format == 1:
d1 = self.display_cal[cal](start) # numerical
d2 = self.display_cal[cal](stop) value = self.dd_dformat01(date_val)
text = "vuosien %s ja %s välillä" % (d1, d2) # elif self.format == 4:
else:
d1 = self.display_cal[cal](start)
d2 = self.display_cal[cal](stop)
text = "%s ja %s välillä" % (d1, d2)
else: else:
text = self.display_cal[date.get_calendar()](start) # day month_name year
if mod == Date.MOD_AFTER: value = self.dd_dformat04(date_val, inflect, long_months)
text = text + " jälkeen" if date_val[2] < 0:
elif mod == Date.MOD_ABOUT: # TODO fix BUG 7064: non-Gregorian calendars wrongly use BCE notation for negative dates
text = "noin " + text return self._bce_str % value
elif mod == Date.MOD_BEFORE: else:
text = "ennen " + text return value
if qual: def dd_dformat04(self, date_val, inflect, long_months):
# prepend quality """
text = "%s %s" % (self._qual_str[qual], text) day month_name year -- for Finnish locale
"""
if cal or newyear: year = self._slash_year(date_val[2], date_val[3])
# append calendar type if date_val[0] == 0:
scal = self.format_extras(cal, newyear) if date_val[1] == 0:
text = "%s %s" % (text, scal) return year
else:
return text if inflect:
return self.format_long_month_year(date_val[1], year,
inflect, long_months)
else:
return "{long_month.f[IN]} {year}".format(
long_month = long_months[date_val[1]],
year = year)
else:
if not hasattr(long_months[date_val[1]], 'f'): # not a Lexeme
return self.dd_dformat01(date_val) # maybe the month is zero
return "{day:d}. {long_month.f[P]} {year}".format(
day = date_val[0],
long_month = long_months[date_val[1]],
year = year)
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# Register classes # Register classes
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
register_datehandler(('fi_FI', 'fi', 'finnish', 'Finnish'), DateParserFI, DateDisplayFI) register_datehandler(('fi_FI', 'fi', 'finnish', 'Finnish'),
DateParserFI, DateDisplayFI)