added and/or clarified various date handler comments

also slightly reformatted a few date handler lines
and fixed one (locale-specific) date handler typo


svn: r22672
This commit is contained in:
Paul Franklin 2013-07-13 18:01:08 +00:00
parent c7ad6127da
commit e4cbeaef19
25 changed files with 152 additions and 94 deletions

View File

@ -168,7 +168,7 @@ class DateParserBG(DateParser):
_span_2 = ['до']
_range_1 = ['между']
_range_2 = ['и']
self._span = re.compile("(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
self._span = re.compile("(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
('|'.join(_span_1), '|'.join(_span_2)),
re.IGNORECASE)
self._range = re.compile("(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
@ -211,6 +211,8 @@ class DateDisplayBG(DateDisplay):
formats = (
"ГГГГ-ММ-ДД (ISO)", "Числов", "Месец Ден, Година", "Мес. Ден, Година", "Ден Месец Година", "Ден Мес. Година"
)
# this must agree with DateDisplayEn's "formats" definition
# (since no locale-specific _display_gregorian exists, here)
hebrew = ( "",
"Тишрей",

View File

@ -102,7 +102,7 @@ class DateParserCA(DateParser):
_span_2 = ['fins a']
_range_1 = ['entre', 'ent\.', 'ent']
_range_2 = ['i']
self._span = re.compile("(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
self._span = re.compile("(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
('|'.join(_span_1), '|'.join(_span_2)),
re.IGNORECASE)
self._range = re.compile("(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
@ -156,6 +156,8 @@ class DateDisplayCA(DateDisplay):
"AAAA-MM-DD (ISO)", "Numèrica", "Mes Dia, Any",
"MES Dia, Any", "Dia Mes, Any", "Dia MES, Any"
)
# this must agree with DateDisplayEn's "formats" definition
# (since no locale-specific _display_gregorian exists, here)
def display(self, date):
"""

View File

@ -218,7 +218,8 @@ class DateDisplayCZ(DateDisplay):
"den. měsíc rok",
"den. měs rok"
)
# this must agree with DateDisplayEn's "formats" definition
# (since no locale-specific _display_gregorian exists, here)
def display(self, date):
"""

View File

@ -121,6 +121,8 @@ class DateDisplayDa(DateDisplay):
"Dag måned år",
"Dag md År",
)
# this must agree with DateDisplayEn's "formats" definition
# (since no locale-specific _display_gregorian exists, here)
calendar = (
"",

View File

@ -221,12 +221,18 @@ class DateDisplayDE(DateDisplay):
"JJJJ-MM-DD (ISO)", "Numerisch", "Monat Tag Jahr",
"MONAT Tag Jahr", "Tag. Monat Jahr", "Tag. MONAT Jahr"
)
# this definition must agree with its "_display_gregorian" method
def _display_gregorian(self, date_val):
"""
display gregorian calendar date in different format
"""
# this must agree with its locale-specific "formats" definition
year = self._slash_year(date_val[2], date_val[3])
if self.format == 0:
return self.display_iso(date_val)
elif self.format == 1:
# day.month_number.year
if date_val[3]:
return self.display_iso(date_val)
else:
@ -237,7 +243,7 @@ class DateDisplayDE(DateDisplay):
value = value.replace('%d', str(date_val[0]))
value = value.replace('%Y', str(date_val[2]))
elif self.format == 2:
# Month Day, Year
# month_name day, year
if date_val[0] == 0:
if date_val[1] == 0:
value = year
@ -247,7 +253,7 @@ class DateDisplayDE(DateDisplay):
value = "%s %d, %s" % (self.long_months[date_val[1]],
date_val[0], year)
elif self.format == 3:
# MON Day, Year
# month_abbreviation day, year
if date_val[0] == 0:
if date_val[1] == 0:
value = year
@ -257,7 +263,7 @@ class DateDisplayDE(DateDisplay):
value = "%s %d, %s" % (self.short_months[date_val[1]],
date_val[0], year)
elif self.format == 4:
# Day Month Year
# day. month_name year
if date_val[0] == 0:
if date_val[1] == 0:
value = year
@ -267,7 +273,7 @@ class DateDisplayDE(DateDisplay):
value = "%d. %s %s" % (date_val[0],
self.long_months[date_val[1]], year)
else:
# Day MON Year
# day. month_abbreviation year
if date_val[0] == 0:
if date_val[1] == 0:
value = year

View File

@ -101,7 +101,7 @@ class DateParserES(DateParser):
_span_2 = ['a']
_range_1 = ['entre', 'ent\.', 'ent']
_range_2 = ['y']
self._span = re.compile("(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
self._span = re.compile("(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
('|'.join(_span_1), '|'.join(_span_2)),
re.IGNORECASE)
self._range = re.compile("(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
@ -140,6 +140,8 @@ class DateDisplayES(DateDisplay):
"AAAA-MM-DD (ISO)", "Numérica", "Mes Día, Año",
"MES Día, Año", "Día Mes, Año", "Día MES, Año"
)
# this must agree with DateDisplayEn's "formats" definition
# (since no locale-specific _display_gregorian exists, here)
def display(self, date):
"""

View File

@ -141,6 +141,8 @@ class DateDisplayFI(DateDisplay):
"VVVV-KK-PP (ISO)",
"PP.KK.VVVV"
)
# this must agree with DateDisplayEn's "formats" definition
# (since no locale-specific _display_gregorian exists, here)
def display(self, date):
"""

View File

@ -285,11 +285,13 @@ class DateDisplayFR(DateDisplay):
"Mois Jour, Année", # 6
"MOI Jour, Année", # 7
)
# this definition must agree with its "_display_gregorian" method
def _display_gregorian(self, date_val):
"""
display gregorian calendar date in different format
"""
# this must agree with its locale-specific "formats" definition
year = self._slash_year(date_val[2], date_val[3])
if self.format == 0:
@ -316,7 +318,7 @@ class DateDisplayFR(DateDisplay):
value = value.replace('%Y', str(date_val[2]))
elif self.format == 2:
# Day Month Year
# day month_name year
if date_val[0] == 0:
if date_val[1] == 0:
@ -329,7 +331,7 @@ class DateDisplayFR(DateDisplay):
self.long_months[date_val[1]], year)
elif self.format == 3:
# Day MON Year
# day month_abbreviation year
if date_val[0] == 0:
if date_val[1] == 0:
@ -342,7 +344,7 @@ class DateDisplayFR(DateDisplay):
self.short_months[date_val[1]], year)
elif self.format == 4:
# Day. Month Year
# day. month_name year
if date_val[0] == 0:
if date_val[1] == 0:
@ -360,7 +362,7 @@ class DateDisplayFR(DateDisplay):
year)
elif self.format == 5:
# Day. MON Year
# day. month_abbreviation year
if date_val[0] == 0:
if date_val[1] == 0:
@ -377,7 +379,7 @@ class DateDisplayFR(DateDisplay):
self.short_months[date_val[1]], year)
elif self.format == 6:
# Month Day, Year
# month_name day, year
if date_val[0] == 0:
if date_val[1] == 0:
@ -389,7 +391,7 @@ class DateDisplayFR(DateDisplay):
date_val[0], year)
elif self.format == 7:
# MON Day, Year
# month_abbreviation day, year
if date_val[0] == 0:
if date_val[1] == 0:

View File

@ -247,6 +247,7 @@ class DateDisplayHR(DateDisplay):
"D. MMMM GGGG.",
"D. Rb GGGG."
)
# this definition must agree with its "_display_gregorian" method
roman_months = (
"",
@ -268,10 +269,12 @@ class DateDisplayHR(DateDisplay):
"""
display gregorian calendar date in different format
"""
# this must agree with its locale-specific "formats" definition
year = self._slash_year(date_val[2], date_val[3])
if self.format == 0:
return self.display_iso(date_val)
elif self.format == 1:
# numerical
if date_val[3]:
return self.display_iso(date_val)
else:
@ -283,7 +286,7 @@ class DateDisplayHR(DateDisplay):
value = value.replace('%Y', str(abs(date_val[2])))
value = value.replace('-', '/')
elif self.format == 2:
# Day.Month.Year.
# day.month_number.year.
if date_val[0] == 0:
if date_val[1] == 0:
value = year
@ -292,7 +295,7 @@ class DateDisplayHR(DateDisplay):
else:
value = "%s.%d.%s." % (date_val[0], date_val[1], year)
elif self.format == 3:
# Day. MONTH year.
# day. month_name year.
if date_val[0] == 0:
if date_val[1] == 0:
value = "%s." % year
@ -300,9 +303,9 @@ class DateDisplayHR(DateDisplay):
value = "%s %s." % (self.long_months[date_val[1]], year)
else:
value = "%d. %s %s." % (date_val[0],
self.long_months[date_val[1]], year)
self.long_months[date_val[1]], year)
else:
# Day RomanMon Year
# day. Roman_number_month year.
if date_val[0] == 0:
if date_val[1] == 0:
value = "%s." % year
@ -310,7 +313,7 @@ class DateDisplayHR(DateDisplay):
value = "%s %s." % (self.roman_months[date_val[1]], year)
else:
value = "%d. %s %s." % (date_val[0],
self.roman_months[date_val[1]], year)
self.roman_months[date_val[1]], year)
if date_val[2] < 0:
return self._bce_str % value
else:

View File

@ -98,7 +98,7 @@ class DateParserIT(DateParser):
_span_2 = ['al', 'a']
_range_1 = ['tra', 'fra']
_range_2 = ['e']
self._span = re.compile("(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
self._span = re.compile("(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
('|'.join(_span_1), '|'.join(_span_2)),
re.IGNORECASE)
self._range = re.compile("(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
@ -152,6 +152,8 @@ class DateDisplayIT(DateDisplay):
"AAAA-MM-DD (ISO)", "Numerico", "Mese Giorno Anno",
"MES Giorno, Anno", "Giorno Mese Anno", "Giorno MES Anno"
)
# this must agree with DateDisplayEn's "formats" definition
# (since no locale-specific _display_gregorian exists, here)
def display(self, date):
"""

View File

@ -136,14 +136,12 @@ class DateParserLT(DateParser):
_span_2 = ['iki']
_range_1 = ['tarp']
_range_2 = ['ir']
self._span = re.compile(
"(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
('|'.join(_span_1), '|'.join(_span_2)),
re.IGNORECASE)
self._range = re.compile(
"(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
('|'.join(_range_1), '|'.join(_range_2)),
re.IGNORECASE)
self._span = re.compile("(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
('|'.join(_span_1), '|'.join(_span_2)),
re.IGNORECASE)
self._range = re.compile("(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
('|'.join(_range_1), '|'.join(_range_2)),
re.IGNORECASE)
#------------------------------------------------------------------------
#
@ -206,32 +204,30 @@ class DateDisplayLT(DateDisplay):
formats = (
"mmmm-MM-DD (ISO)", "mmmm m. mėnesio diena d.", "Mėn diena, metai")
# this definition must agree with its "_display_gregorian" method
def _display_gregorian(self, date_val):
"""
display gregorian calendar date in different format
"""
# this must agree with its locale-specific "formats" definition
value = self.display_iso(date_val)
year = self._slash_year(date_val[2], date_val[3])
if self.format == 0:
return self.display_iso(date_val)
elif self.format == 1:
# mmmm m. mėnesio diena d. (YYYY m. month DD d.)
# mmmm m. mėnesio diena d. (year m. month_name day d.)
if date_val[0] == 0:
if date_val[1] == 0:
value = year
else:
value = "%s m. %s" % (year, self.long_months_vardininkas[date_val[1]])
else:
value = "%s m. %s %d d." % (year, self.long_months[date_val[1]],
date_val[0])
value = "%s m. %s %d d." % (year,
self.long_months[date_val[1]],
date_val[0])
elif self.format == 2:
# MON Day, Year
# month_abbreviation day, year
if date_val[0] == 0:
if date_val[1] == 0:
value = year
@ -240,8 +236,6 @@ class DateDisplayLT(DateDisplay):
else:
value = "%s %d, %s" % (self.short_months[date_val[1]],
date_val[0], year)
if date_val[2] < 0:
return self._bce_str % value
else:

View File

@ -121,6 +121,8 @@ class DateDisplayNb(DateDisplay):
"Dag måned år",
"Dag Mån År",
)
# this must agree with DateDisplayEn's "formats" definition
# (since no locale-specific _display_gregorian exists, here)
calendar = (
"",

View File

@ -165,8 +165,13 @@ class DateDisplayNL(DateDisplay):
"JJJJ-MM-DD (ISO)", "Numerisch DD/MM/JJ", "Maand Dag, Jaar",
"Mnd. Dag Jaar", "Dag Maand Jaar", "Dag Mnd. Jaar"
)
# this definition must agree with its "_display_gregorian" method
def _display_gregorian(self, date_val):
"""
display gregorian calendar date in different format
"""
# this must agree with its locale-specific "formats" definition
year = self._slash_year(date_val[2], date_val[3])
if self.format == 0:
return self.display_iso(date_val)
@ -174,7 +179,7 @@ class DateDisplayNL(DateDisplay):
if date_val[3]:
return self.display_iso(date_val)
else:
# Numeric
# day/month_number/year
if date_val[0] == date_val[1] == 0:
value = str(date_val[2])
else:
@ -183,7 +188,7 @@ class DateDisplayNL(DateDisplay):
value = value.replace('%Y', str(abs(date_val[2])))
value = value.replace('-', '/')
elif self.format == 2:
# Month Day, Year
# month_name day, year
if date_val[0] == 0:
if date_val[1] == 0:
value = year
@ -193,7 +198,7 @@ class DateDisplayNL(DateDisplay):
value = "%s %d, %s" % (self.long_months[date_val[1]],
date_val[0], year)
elif self.format == 3:
# Mnd Day, Year
# month_abbreviation day, year
if date_val[0] == 0:
if date_val[1] == 0:
value = year
@ -203,7 +208,7 @@ class DateDisplayNL(DateDisplay):
value = "%s %d, %s" % (self.short_months[date_val[1]],
date_val[0], year)
elif self.format == 4:
# Day Month Year
# day month_name year
if date_val[0] == 0:
if date_val[1] == 0:
value = year
@ -213,7 +218,7 @@ class DateDisplayNL(DateDisplay):
value = "%d %s %s" % (date_val[0],
self.long_months[date_val[1]], year)
else:
# Day Mnd Year
# day month_abbreviation year
if date_val[0] == 0:
if date_val[1] == 0:
value = year
@ -221,7 +226,7 @@ class DateDisplayNL(DateDisplay):
value = "%s %s" % (self.short_months[date_val[1]], year)
else:
value = "%d %s %s" % (date_val[0],
self.short_months[date_val[1]], year)
self.short_months[date_val[1]], year)
if date_val[2] < 0:
return self._bce_str % value
else:

View File

@ -199,6 +199,7 @@ class DateDisplayPL(DateDisplay):
"RRRR-MM-DD (ISO)", "Numeryczny", "Miesiąc Dzień, Rok",
"Dzień.Miesiąc.Rok", "Dzień Miesiąc Rok", "Dzień MieRzym Rok"
)
# this definition must agree with its "_display_gregorian" method
roman_months = (
"",
@ -217,10 +218,15 @@ class DateDisplayPL(DateDisplay):
)
def _display_gregorian(self, date_val):
"""
display gregorian calendar date in different format
"""
# this must agree with its locale-specific "formats" definition
year = self._slash_year(date_val[2], date_val[3])
if self.format == 0:
return self.display_iso(date_val)
elif self.format == 1:
# month_number.day.year
if date_val[3]:
return self.display_iso(date_val)
else:
@ -229,9 +235,9 @@ class DateDisplayPL(DateDisplay):
else:
value = self._tformat.replace('%m', str(date_val[0]))
value = value.replace('%d', str(date_val[1]))
value = value.replace('%y', str(date_val[2]))
value = value.replace('%Y', str(date_val[2]))
elif self.format == 2:
# Month Day, Year
# month_name day, year
if date_val[0] == 0:
if date_val[1] == 0:
value = year
@ -241,7 +247,7 @@ class DateDisplayPL(DateDisplay):
value = "%s %d, %s" % (self.long_months[date_val[1]],
date_val[0], year)
elif self.format == 3:
# Day. Month. Year
# day. month_number. year
if date_val[0] == 0:
if date_val[1] == 0:
value = year
@ -250,7 +256,7 @@ class DateDisplayPL(DateDisplay):
else:
value = "%d.%d.%s" % (date_val[0], date_val[1], year)
elif self.format == 4:
# Day Month Year
# day month_name year
if date_val[0] == 0:
if date_val[1] == 0:
value = year
@ -260,7 +266,7 @@ class DateDisplayPL(DateDisplay):
value = "%d %s %s" % (date_val[0],
self.long_months[date_val[1]], year)
else:
# Day RomanMon Year
# day Roman_number_month year
if date_val[0] == 0:
if date_val[1] == 0:
value = year

View File

@ -106,12 +106,12 @@ class DateParserPT(DateParser):
_span_2 = ['a']
_range_1 = ['entre','ent\.','ent']
_range_2 = ['e']
self._span = re.compile("(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
('|'.join(_span_1),'|'.join(_span_2)),
re.IGNORECASE)
self._range = re.compile("(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
('|'.join(_range_1),'|'.join(_range_2)),
re.IGNORECASE)
self._span = re.compile("(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
('|'.join(_span_1), '|'.join(_span_2)),
re.IGNORECASE)
self._range = re.compile("(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
('|'.join(_range_1), '|'.join(_range_2)),
re.IGNORECASE)
#-------------------------------------------------------------------------
#
@ -143,6 +143,8 @@ class DateDisplayPT(DateDisplay):
"AAAA-MM-DD (ISO)", "Numérica", "Mês Dia, Ano",
"MÊS Dia, Ano", "Dia Mês, Ano", "Dia MÊS, Ano"
)
# this must agree with DateDisplayEn's "formats" definition
# (since no locale-specific _display_gregorian exists, here)
def display(self,date):
"""

View File

@ -222,12 +222,12 @@ class DateParserRU(DateParser):
_span_2 = ['по']
_range_1 = ['между', 'меж\.', 'меж']
_range_2 = ['и']
self._span = re.compile("(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
('|'.join(_span_1), '|'.join(_span_2)),
re.IGNORECASE)
self._range = re.compile("(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
('|'.join(_range_1), '|'.join(_range_2)),
re.IGNORECASE)
self._span = re.compile("(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
('|'.join(_span_1), '|'.join(_span_2)),
re.IGNORECASE)
self._range = re.compile("(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
('|'.join(_range_1), '|'.join(_range_2)),
re.IGNORECASE)
#-------------------------------------------------------------------------
#
@ -270,6 +270,8 @@ class DateDisplayRU(DateDisplay):
"ГГГГ-ММ-ДД (ISO)", "Численный", "Месяц День, Год",
"МЕС ДД, ГГГГ", "День Месяц, Год", "ДД МЕС, ГГГГ"
)
# this must agree with DateDisplayEn's "formats" definition
# (since no locale-specific _display_gregorian exists, here)
hebrew = ( "",
"тишрея",

View File

@ -88,7 +88,7 @@ class DateParserSK(DateParser):
_span_2 = ['do']
_range_1 = ['medzi']
_range_2 = ['a']
self._span = re.compile("(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
self._span = re.compile("(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
('|'.join(_span_1), '|'.join(_span_2)),
re.IGNORECASE)
self._range = re.compile("(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
@ -125,6 +125,8 @@ class DateDisplaySK(DateDisplay):
"RRRR-MM-DD (ISO)", "numerický", "Mesiac Deň, Rok",
"MES Deň, Rok", "Deň, Mesiac, Rok", "Deň MES Rok"
)
# this must agree with DateDisplayEn's "formats" definition
# (since no locale-specific _display_gregorian exists, here)
def display(self, date):
"""

View File

@ -223,16 +223,18 @@ class DateDisplaySL(DateDisplay):
"dan. mes. leto",
"dan. mesec leto"
)
# this definition must agree with its "_display_gregorian" method
def _display_gregorian(self, date_val):
"""
display gregorian calendar date in different format
"""
# this must agree with its locale-specific "formats" definition
year = self._slash_year(date_val[2], date_val[3])
if self.format == 0:
return self.display_iso(date_val)
elif self.format == 1:
# D. M. YYYY
# day. month_number. year
if date_val[3]:
return self.display_iso(date_val)
else:
@ -244,7 +246,7 @@ class DateDisplaySL(DateDisplay):
value = value.replace('%Y', str(date_val[2]))
value = value.replace('-', '. ')
elif self.format == 2:
# D. mon. YYYY
# day. month_abbreviation. year
if date_val[0] == 0:
if date_val[1] == 0:
value = year
@ -254,7 +256,7 @@ class DateDisplaySL(DateDisplay):
value = "%d. %s. %s" % (date_val[0],
self.short_months[date_val[1]], year)
else:
# D. month YYYY
# day. month_name year
if date_val[0] == 0:
if date_val[1] == 0:
value = "%s." % year

View File

@ -220,12 +220,12 @@ class DateParserSR(DateParser):
_span_2 = ['do', 'до']
_range_1 = ['između', 'између']
_range_2 = ['i', 'и']
self._span = re.compile("(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
('|'.join(_span_1),'|'.join(_span_2)),
re.IGNORECASE)
self._span = re.compile("(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
('|'.join(_span_1), '|'.join(_span_2)),
re.IGNORECASE)
self._range = re.compile("(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
('|'.join(_range_1),'|'.join(_range_2)),
re.IGNORECASE)
('|'.join(_range_1), '|'.join(_range_2)),
re.IGNORECASE)
#-------------------------------------------------------------------------
#
@ -271,17 +271,18 @@ class DateDisplaySR_latin(DateDisplay):
"D. Mesec GGGG.",
"D. Rb GGGG."
)
# this definition must agree with its "_display_gregorian" method
def _display_gregorian(self, date_val):
"""
display gregorian calendar date in different format
"""
# this must agree with its locale-specific "formats" definition
year = self._slash_year(date_val[2], date_val[3])
if self.format == 0:
return self.display_iso(date_val)
elif self.format == 1:
## DD.MM.YYYY.
# day.month_number.year.
if date_val[3]:
return self.display_iso(date_val)
else:
@ -294,7 +295,7 @@ class DateDisplaySR_latin(DateDisplay):
#some locale magic already provides the right separator
#value = value.replace('/', '.')
elif self.format == 2:
# Day. MON Year.
# day. month_abbreviation year.
if date_val[0] == 0:
if date_val[1] == 0:
value = "%s." % year
@ -302,9 +303,9 @@ class DateDisplaySR_latin(DateDisplay):
value = "%s %s." % (self.short_months[date_val[1]], year)
else:
value = "%d. %s %s." % (date_val[0],
self.short_months[date_val[1]], year)
self.short_months[date_val[1]], year)
elif self.format == 3:
# Day. MONTH Year.
# day. month_name year.
if date_val[0] == 0:
if date_val[1] == 0:
value = "%s." % year
@ -312,9 +313,9 @@ class DateDisplaySR_latin(DateDisplay):
value = "%s %s." % (self.long_months[date_val[1]], year)
else:
value = "%d. %s %s." % (date_val[0],
self.long_months[date_val[1]], year)
self.long_months[date_val[1]], year)
else:
# Day RomanMon Year
# day. Roman_number_month year.
if date_val[0] == 0:
if date_val[1] == 0:
value = "%s." % year
@ -322,7 +323,7 @@ class DateDisplaySR_latin(DateDisplay):
value = "%s %s." % (self.roman_months[date_val[1]], year)
else:
value = "%d. %s %s." % (date_val[0],
self.roman_months[date_val[1]], year)
self.roman_months[date_val[1]], year)
if date_val[2] < 0:
return self._bce_str % value
else:

View File

@ -126,6 +126,8 @@ class DateDisplaySv(DateDisplay):
"Dag månad år",
"DAG MÅN ÅR",
)
# this must agree with DateDisplayEn's "formats" definition
# (since no locale-specific _display_gregorian exists, here)
calendar = (
"",

View File

@ -226,16 +226,14 @@ class DateParserUK(DateParser):
_span_1 = ['з', 'від']
# b.c.e. pattern also have "до" so skip "до н."
_span_2 = ['по', 'до?!\\.']
self._span = re.compile("(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
('|'.join(_span_1), '|'.join(_span_2)),
re.IGNORECASE)
_range_1 = ['між']
_range_2 = ['і', 'та']
self._span = re.compile("(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
('|'.join(_span_1), '|'.join(_span_2)),
re.IGNORECASE)
self._range = re.compile("(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
('|'.join(_range_1), '|'.join(_range_2)),
re.IGNORECASE)
('|'.join(_range_1), '|'.join(_range_2)),
re.IGNORECASE)
#-------------------------------------------------------------------------
#
@ -309,6 +307,8 @@ class DateDisplayUK(DateDisplay):
"день місяць рік", #4
"дд міс. рррр" #5
)
# this must agree with DateDisplayEn's "formats" definition
# (since no locale-specific _display_gregorian exists, here)
calendar = (
"", "юліанський", "єврейський", "французький республіканський",

View File

@ -103,19 +103,24 @@ class DateDisplay(object):
)
formats = ("YYYY-MM-DD (ISO)", )
# this will be overridden if a locale-specific date displayer exists
calendar = (
"", "Julian", "Hebrew", "French Republican",
"Persian", "Islamic", "Swedish"
)
# this will be overridden if a locale-specific date displayer exists
newyear = ("", "Mar1", "Mar25", "Sep1")
_mod_str = ("", "before ", "after ", "about ", "", "", "")
# this will be overridden if a locale-specific date displayer exists
_qual_str = ("", "estimated ", "calculated ")
# this will be overridden if a locale-specific date displayer exists
_bce_str = "%s B.C.E."
# this will be overridden if a locale-specific date displayer exists
def __init__(self, format=None):
self.display_cal = [
@ -159,6 +164,7 @@ class DateDisplay(object):
def display(self, date):
"""
Return a text string representing the date.
(will be overridden if a locale-specific date displayer exists)
"""
mod = date.get_modifier()
cal = date.get_calendar()
@ -213,10 +219,13 @@ class DateDisplay(object):
return value
def _display_gregorian(self, date_val):
# this one must agree with DateDisplayEn's "formats" definition
# (it may be overridden if a locale-specific date displayer exists)
year = self._slash_year(date_val[2], date_val[3])
if self.format == 0:
return self.display_iso(date_val)
elif self.format == 1:
# numerical
if date_val[3]:
return self.display_iso(date_val)
else:
@ -228,7 +237,7 @@ class DateDisplay(object):
value = value.replace('%Y', str(abs(date_val[2])))
value = value.replace('-', '/')
elif self.format == 2:
# Month Day, Year
# month_name day, year
if date_val[0] == 0:
if date_val[1] == 0:
value = year
@ -238,7 +247,7 @@ class DateDisplay(object):
value = "%s %d, %s" % (self.long_months[date_val[1]],
date_val[0], year)
elif self.format == 3:
# MON Day, Year
# month_abbreviation day, year
if date_val[0] == 0:
if date_val[1] == 0:
value = year
@ -248,7 +257,7 @@ class DateDisplay(object):
value = "%s %d, %s" % (self.short_months[date_val[1]],
date_val[0], year)
elif self.format == 4:
# Day Month Year
# day month_name year
if date_val[0] == 0:
if date_val[1] == 0:
value = year
@ -257,8 +266,9 @@ class DateDisplay(object):
else:
value = "%d %s %s" % (date_val[0],
self.long_months[date_val[1]], year)
# elif self.format == 5:
else:
# Day MON Year
# day month_abbreviation year
if date_val[0] == 0:
if date_val[1] == 0:
value = year
@ -277,6 +287,7 @@ class DateDisplay(object):
return self._display_gregorian(date_val)
def _display_calendar(self, date_val, month_list):
# used to display non-Gregorian calendars (Hebrew, Islamic, etc.)
year = abs(date_val[2])
if self.format == 0 or self.format == 1:
return self.display_iso(date_val)
@ -333,6 +344,7 @@ class DateDisplayEn(DateDisplay):
"YYYY-MM-DD (ISO)", "Numerical", "Month Day, Year",
"MON DAY, YEAR", "Day Month Year", "DAY MON YEAR"
)
# this (English) "formats" must agree with "_display_gregorian" (above)
def __init__(self, format=None):
"""

View File

@ -49,6 +49,7 @@ from ._dateparser import DateParser
from ._datedisplay import DateDisplay, DateDisplayEn
from ..constfunc import win, cuni
from ..const import GRAMPS_LOCALE as glocale
#-------------------------------------------------------------------------
#
# Constants

View File

@ -23,8 +23,7 @@
"""
Date parsing class. Serves as the base class for any localized
date parsing class. The default, base class provides parsing for
English.
date parsing class. The default base class provides parsing for English.
"""
#-------------------------------------------------------------------------
@ -145,6 +144,7 @@ class DateParser(object):
month_to_int = _grampslocale.month_to_int
# modifiers before the date
# (overridden if a locale-specific date parser exists)
modifier_to_int = {
'before' : Date.MOD_BEFORE, 'bef' : Date.MOD_BEFORE,
'bef.' : Date.MOD_BEFORE, 'after' : Date.MOD_AFTER,
@ -227,6 +227,7 @@ class DateParser(object):
bce = ["B.C.E.", "B.C.E", "BCE", "B.C.", "B.C", "BC" ]
# (overridden if a locale-specific date parser exists)
calendar_to_int = {
'gregorian' : Date.CAL_GREGORIAN,
@ -245,6 +246,7 @@ class DateParser(object):
'swedish' : Date.CAL_SWEDISH,
's' : Date.CAL_SWEDISH,
}
# (probably overridden if a locale-specific date parser exists)
newyear_to_int = {
"jan1": Date.NEWYEAR_JAN1,
@ -261,6 +263,7 @@ class DateParser(object):
'calc' : Date.QUAL_CALCULATED,
'calculated' : Date.QUAL_CALCULATED,
}
# (overridden if a locale-specific date parser exists)
def __init__(self):
self.init_strings()

View File

@ -30,13 +30,13 @@ Class handling language-specific selection for date parser and displayer.
#
#-------------------------------------------------------------------------
import time
from ..lib.date import Date
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from ..lib.date import Date
from . import LANG_TO_DISPLAY, LANG, parser, displayer
#--------------------------------------------------------------
@ -46,7 +46,7 @@ from . import LANG_TO_DISPLAY, LANG, parser, displayer
#--------------------------------------------------------------
def get_date_formats():
"""
Return the lists supported formats for date parsers and displayers.
Return the list of supported formats for date parsers and displayers.
"""
try:
return LANG_TO_DISPLAY[LANG].formats