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: r22670
This commit is contained in:
Paul Franklin 2013-07-13 18:00:11 +00:00
parent 9dae34ec84
commit 6507c468bf
25 changed files with 163 additions and 126 deletions

View File

@ -102,19 +102,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 = [
@ -158,6 +163,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()
@ -212,10 +218,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:
@ -227,7 +236,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
@ -237,7 +246,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
@ -247,7 +256,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
@ -256,8 +265,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
@ -276,6 +286,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)
@ -332,6 +343,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

@ -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.
"""
#-------------------------------------------------------------------------
@ -143,6 +142,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,
@ -225,6 +225,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,
@ -243,6 +244,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,
@ -259,6 +261,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

@ -38,7 +38,7 @@ from DateHandler 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

View File

@ -32,15 +32,6 @@ Arabic-specific classes for parsing and displaying dates.
#-------------------------------------------------------------------------
from __future__ import unicode_literals
import re
import calendar
#-------------------------------------------------------------------------
#
# set up logging
#
#-------------------------------------------------------------------------
import logging
log = logging.getLogger(".DateParser")
#-------------------------------------------------------------------------
#
@ -63,7 +54,6 @@ class DateParserAR(DateParser):
converted, the text string is assigned.
"""
# modifiers before the date
modifier_to_int = {
'قبل' : Date.MOD_BEFORE,
@ -147,7 +137,6 @@ class DateParserAR(DateParser):
"november" : 11, "december" : 12,
}
bce = ["قبل الميلاد", "قبل الميلاد", "قبل الميلاد", "قبل الميلاد", "قبل الميلاد", "قبل الميلاد" ]
calendar_to_int = {
@ -180,26 +169,18 @@ class DateParserAR(DateParser):
def init_strings(self):
"""
This method compiles regular expression strings for matching dates.
Most of the re's in most languages can stay as is. span and range
most likely will need to change. Whatever change is done, this method
may be called first as DateParser.init_strings(self) so that the
invariant expresions don't need to be repeteadly coded. All differences
can be coded after DateParser.init_strings(self) call, that way they
override stuff from this method. See DateParserRU() as an example.
"""
DateParser.init_strings(self)
# In the following you should translate from and to as in a date
# from 2001 to 2004 and then test if it works for LTR
self._span = re.compile("من\s+(?P<start>.+)\s+إلى\s+(?P<stop>.+)",
re.IGNORECASE)
# In following you must translate bet|bet.|between and 'and' as in a
# date between 2001 and 2002
# Here you see between can be written in 3 different ways, you
#can allow the same in arabic
self._range = re.compile("بين\s+(?P<start>.+)\s+و\s+(?P<stop>.+)",
re.IGNORECASE)
_span_1 = [u'من']
_span_2 = [u'إلى']
_range_1 = [u'بين']
_range_2 = [u'و']
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)
#-------------------------------------------------------------------------
#
@ -261,11 +242,12 @@ class DateDisplayAR(DateDisplay):
"Oktober", "November", "December"
)
#Following are the formats for date display you can set in the preferences
formats = (
"YYYY-MM-DD (قياسي)", "عددي", "شهر يوم, سنة",
"شهر يوم, سنة", "يوم شهر سنة", "يوم شهر سنة"
)
# this must agree with DateDisplayEn's "formats" definition
# (since no locale-specific _display_gregorian exists, here)
calendar = (
"", "يوليوسي", "عبري", "فرنسي",
@ -298,13 +280,11 @@ class DateDisplayAR(DateDisplay):
d1 = self.display_cal[cal](start)
d2 = self.display_cal[cal](date.get_stop_date())
scal = self.format_extras(cal, newyear)
# translate from and to
return "%s%s %s %s %s%s" % (qual_str, 'من', d1, 'إلى', d2, scal)
elif mod == Date.MOD_RANGE:
d1 = self.display_cal[cal](start)
d2 = self.display_cal[cal](date.get_stop_date())
scal = self.format_extras(cal, newyear)
# translate between and and
return "%s%s %s %s %s%s" % (qual_str, 'بين', d1, 'و', d2, scal)
else:
text = self.display_cal[date.get_calendar()](start)

View File

@ -168,7 +168,7 @@ class DateParserBG(DateParser):
_span_2 = [u'до']
_range_1 = [u'между']
_range_2 = [u'и']
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 = ( u"",
u"Тишрей",

View File

@ -103,7 +103,7 @@ class DateParserCA(DateParser):
_span_2 = [u'fins a']
_range_1 = [u'entre', u'ent\.', u'ent']
_range_2 = [u'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>.+)" %
@ -157,6 +157,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

@ -219,7 +219,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

@ -122,6 +122,8 @@ class DateDisplayDa(DateDisplay):
u"Dag måned år",
u"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 = [u'a']
_range_1 = [u'entre', u'ent\.', u'ent']
_range_2 = [u'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

@ -248,6 +248,7 @@ class DateDisplayHR(DateDisplay):
"D. MMMM GGGG.",
"D. Rb GGGG."
)
# this definition must agree with its "_display_gregorian" method
roman_months = (
"",
@ -269,10 +270,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:
@ -284,7 +287,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
@ -293,7 +296,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 = u"%s." % year
@ -301,9 +304,9 @@ class DateDisplayHR(DateDisplay):
value = u"%s %s." % (self.long_months[date_val[1]], year)
else:
value = u"%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 = u"%s." % year
@ -311,7 +314,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

@ -99,7 +99,7 @@ class DateParserIT(DateParser):
_span_2 = [u'al', u'a']
_range_1 = [u'tra', u'fra']
_range_2 = [u'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>.+)" %
@ -153,6 +153,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 = [u'iki']
_range_1 = [u'tarp']
_range_2 = [u'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):
u"Dag måned år",
u"Dag Mån År",
)
# this must agree with DateDisplayEn's "formats" definition
# (since no locale-specific _display_gregorian exists, here)
calendar = (
"",

View File

@ -164,8 +164,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)
@ -173,7 +178,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:
@ -182,7 +187,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
@ -192,7 +197,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
@ -202,7 +207,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
@ -212,7 +217,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
@ -220,7 +225,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

@ -200,6 +200,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 = (
"",
@ -218,10 +219,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:
@ -230,9 +236,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
@ -242,7 +248,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
@ -251,7 +257,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
@ -261,7 +267,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 = [u'a']
_range_1 = [u'entre',u'ent\.',u'ent']
_range_2 = [u'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 = [u'по']
_range_1 = [u'между', u'меж\.', u'меж']
_range_2 = [u'и']
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 = ( u"",
u"тишрея",

View File

@ -88,7 +88,7 @@ class DateParserSK(DateParser):
_span_2 = [u'do']
_range_1 = [u'medzi']
_range_2 = [u'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

@ -224,16 +224,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:
@ -245,7 +247,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
@ -255,7 +257,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

@ -221,12 +221,12 @@ class DateParserSR(DateParser):
_span_2 = [u'do', u'до']
_range_1 = [u'između', u'између']
_range_2 = [u'i', u'и']
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)
#-------------------------------------------------------------------------
#
@ -272,17 +272,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:
@ -295,7 +296,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 = u"%s." % year
@ -303,9 +304,9 @@ class DateDisplaySR_latin(DateDisplay):
value = u"%s %s." % (self.short_months[date_val[1]], year)
else:
value = u"%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 = u"%s." % year
@ -313,9 +314,9 @@ class DateDisplaySR_latin(DateDisplay):
value = u"%s %s." % (self.long_months[date_val[1]], year)
else:
value = u"%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 = u"%s." % year
@ -323,7 +324,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):
u"Dag månad år",
u"DAG MÅN ÅR",
)
# this must agree with DateDisplayEn's "formats" definition
# (since no locale-specific _display_gregorian exists, here)
calendar = (
u"",

View File

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