diff --git a/src/DateHandler/_DateDisplay.py b/src/DateHandler/_DateDisplay.py index 53a5e87a5..e76ae1611 100644 --- a/src/DateHandler/_DateDisplay.py +++ b/src/DateHandler/_DateDisplay.py @@ -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): """ diff --git a/src/DateHandler/_DateParser.py b/src/DateHandler/_DateParser.py index 67f71d9aa..17bb32538 100644 --- a/src/DateHandler/_DateParser.py +++ b/src/DateHandler/_DateParser.py @@ -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() diff --git a/src/DateHandler/_DateUtils.py b/src/DateHandler/_DateUtils.py index 7b86932bf..90b0fefa9 100644 --- a/src/DateHandler/_DateUtils.py +++ b/src/DateHandler/_DateUtils.py @@ -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 diff --git a/src/DateHandler/_Date_ar.py b/src/DateHandler/_Date_ar.py index fe2f502e2..4ab3f9c02 100644 --- a/src/DateHandler/_Date_ar.py +++ b/src/DateHandler/_Date_ar.py @@ -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.+)\s+إلى\s+(?P.+)", - 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.+)\s+و\s+(?P.+)", - re.IGNORECASE) + _span_1 = [u'من'] + _span_2 = [u'إلى'] + _range_1 = [u'بين'] + _range_2 = [u'و'] + self._span = re.compile("(%s)\s+(?P.+)\s+(%s)\s+(?P.+)" % + ('|'.join(_span_1), '|'.join(_span_2)), + re.IGNORECASE) + self._range = re.compile("(%s)\s+(?P.+)\s+(%s)\s+(?P.+)" % + ('|'.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) diff --git a/src/DateHandler/_Date_bg.py b/src/DateHandler/_Date_bg.py index 93d05db26..7eac4bafd 100644 --- a/src/DateHandler/_Date_bg.py +++ b/src/DateHandler/_Date_bg.py @@ -168,7 +168,7 @@ class DateParserBG(DateParser): _span_2 = [u'до'] _range_1 = [u'между'] _range_2 = [u'и'] - self._span = re.compile("(%s)\s+(?P.+)\s+(%s)\s+(?P.+)" % + self._span = re.compile("(%s)\s+(?P.+)\s+(%s)\s+(?P.+)" % ('|'.join(_span_1), '|'.join(_span_2)), re.IGNORECASE) self._range = re.compile("(%s)\s+(?P.+)\s+(%s)\s+(?P.+)" % @@ -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"Тишрей", diff --git a/src/DateHandler/_Date_ca.py b/src/DateHandler/_Date_ca.py index 0181e58e1..6c300ddbd 100644 --- a/src/DateHandler/_Date_ca.py +++ b/src/DateHandler/_Date_ca.py @@ -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.+)\s+(%s)\s+(?P.+)" % + self._span = re.compile("(%s)\s+(?P.+)\s+(%s)\s+(?P.+)" % ('|'.join(_span_1), '|'.join(_span_2)), re.IGNORECASE) self._range = re.compile("(%s)\s+(?P.+)\s+(%s)\s+(?P.+)" % @@ -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): """ diff --git a/src/DateHandler/_Date_cs.py b/src/DateHandler/_Date_cs.py index b46f60e9b..2b78ee881 100644 --- a/src/DateHandler/_Date_cs.py +++ b/src/DateHandler/_Date_cs.py @@ -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): """ diff --git a/src/DateHandler/_Date_da.py b/src/DateHandler/_Date_da.py index 1a0074749..67d80c1af 100644 --- a/src/DateHandler/_Date_da.py +++ b/src/DateHandler/_Date_da.py @@ -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 = ( "", diff --git a/src/DateHandler/_Date_de.py b/src/DateHandler/_Date_de.py index 1586433b0..414090bc7 100644 --- a/src/DateHandler/_Date_de.py +++ b/src/DateHandler/_Date_de.py @@ -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 diff --git a/src/DateHandler/_Date_es.py b/src/DateHandler/_Date_es.py index ca01c79b3..b0e6177c1 100644 --- a/src/DateHandler/_Date_es.py +++ b/src/DateHandler/_Date_es.py @@ -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.+)\s+(%s)\s+(?P.+)" % + self._span = re.compile("(%s)\s+(?P.+)\s+(%s)\s+(?P.+)" % ('|'.join(_span_1), '|'.join(_span_2)), re.IGNORECASE) self._range = re.compile("(%s)\s+(?P.+)\s+(%s)\s+(?P.+)" % @@ -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): """ diff --git a/src/DateHandler/_Date_fi.py b/src/DateHandler/_Date_fi.py index 631cb956c..0b8962085 100644 --- a/src/DateHandler/_Date_fi.py +++ b/src/DateHandler/_Date_fi.py @@ -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): """ diff --git a/src/DateHandler/_Date_fr.py b/src/DateHandler/_Date_fr.py index 3e3f101a1..fd5909940 100644 --- a/src/DateHandler/_Date_fr.py +++ b/src/DateHandler/_Date_fr.py @@ -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: diff --git a/src/DateHandler/_Date_hr.py b/src/DateHandler/_Date_hr.py index 08e0243a8..a6c7f1402 100644 --- a/src/DateHandler/_Date_hr.py +++ b/src/DateHandler/_Date_hr.py @@ -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: diff --git a/src/DateHandler/_Date_it.py b/src/DateHandler/_Date_it.py index 3665f1fc6..e6218c5f5 100644 --- a/src/DateHandler/_Date_it.py +++ b/src/DateHandler/_Date_it.py @@ -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.+)\s+(%s)\s+(?P.+)" % + self._span = re.compile("(%s)\s+(?P.+)\s+(%s)\s+(?P.+)" % ('|'.join(_span_1), '|'.join(_span_2)), re.IGNORECASE) self._range = re.compile("(%s)\s+(?P.+)\s+(%s)\s+(?P.+)" % @@ -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): """ diff --git a/src/DateHandler/_Date_lt.py b/src/DateHandler/_Date_lt.py index a6b78e79a..a63923145 100644 --- a/src/DateHandler/_Date_lt.py +++ b/src/DateHandler/_Date_lt.py @@ -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.+)\s+(%s)\s+(?P.+)" % - ('|'.join(_span_1), '|'.join(_span_2)), - re.IGNORECASE) - self._range = re.compile( - "(%s)\s+(?P.+)\s+(%s)\s+(?P.+)" % - ('|'.join(_range_1), '|'.join(_range_2)), - re.IGNORECASE) + self._span = re.compile("(%s)\s+(?P.+)\s+(%s)\s+(?P.+)" % + ('|'.join(_span_1), '|'.join(_span_2)), + re.IGNORECASE) + self._range = re.compile("(%s)\s+(?P.+)\s+(%s)\s+(?P.+)" % + ('|'.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: diff --git a/src/DateHandler/_Date_nb.py b/src/DateHandler/_Date_nb.py index fb7fb2e26..62a4b05e3 100644 --- a/src/DateHandler/_Date_nb.py +++ b/src/DateHandler/_Date_nb.py @@ -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 = ( "", diff --git a/src/DateHandler/_Date_nl.py b/src/DateHandler/_Date_nl.py index 8d4fd95fc..0c37e4562 100644 --- a/src/DateHandler/_Date_nl.py +++ b/src/DateHandler/_Date_nl.py @@ -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: diff --git a/src/DateHandler/_Date_pl.py b/src/DateHandler/_Date_pl.py index e3f7e33ee..7e11fc459 100644 --- a/src/DateHandler/_Date_pl.py +++ b/src/DateHandler/_Date_pl.py @@ -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 diff --git a/src/DateHandler/_Date_pt.py b/src/DateHandler/_Date_pt.py index c0a5e5c86..9a9f1b5fe 100644 --- a/src/DateHandler/_Date_pt.py +++ b/src/DateHandler/_Date_pt.py @@ -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.+)\s+(%s)\s+(?P.+)" % - ('|'.join(_span_1),'|'.join(_span_2)), - re.IGNORECASE) - self._range = re.compile("(%s)\s+(?P.+)\s+(%s)\s+(?P.+)" % - ('|'.join(_range_1),'|'.join(_range_2)), - re.IGNORECASE) + self._span = re.compile("(%s)\s+(?P.+)\s+(%s)\s+(?P.+)" % + ('|'.join(_span_1), '|'.join(_span_2)), + re.IGNORECASE) + self._range = re.compile("(%s)\s+(?P.+)\s+(%s)\s+(?P.+)" % + ('|'.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): """ diff --git a/src/DateHandler/_Date_ru.py b/src/DateHandler/_Date_ru.py index ac497ec23..68cfc2710 100644 --- a/src/DateHandler/_Date_ru.py +++ b/src/DateHandler/_Date_ru.py @@ -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.+)\s+(%s)\s+(?P.+)" % - ('|'.join(_span_1), '|'.join(_span_2)), - re.IGNORECASE) - self._range = re.compile("(%s)\s+(?P.+)\s+(%s)\s+(?P.+)" % - ('|'.join(_range_1), '|'.join(_range_2)), - re.IGNORECASE) + self._span = re.compile("(%s)\s+(?P.+)\s+(%s)\s+(?P.+)" % + ('|'.join(_span_1), '|'.join(_span_2)), + re.IGNORECASE) + self._range = re.compile("(%s)\s+(?P.+)\s+(%s)\s+(?P.+)" % + ('|'.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"тишрея", diff --git a/src/DateHandler/_Date_sk.py b/src/DateHandler/_Date_sk.py index c6e451bc5..244976762 100644 --- a/src/DateHandler/_Date_sk.py +++ b/src/DateHandler/_Date_sk.py @@ -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.+)\s+(%s)\s+(?P.+)" % + self._span = re.compile("(%s)\s+(?P.+)\s+(%s)\s+(?P.+)" % ('|'.join(_span_1), '|'.join(_span_2)), re.IGNORECASE) self._range = re.compile("(%s)\s+(?P.+)\s+(%s)\s+(?P.+)" % @@ -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): """ diff --git a/src/DateHandler/_Date_sl.py b/src/DateHandler/_Date_sl.py index 2e7794653..e593525c6 100644 --- a/src/DateHandler/_Date_sl.py +++ b/src/DateHandler/_Date_sl.py @@ -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 diff --git a/src/DateHandler/_Date_sr.py b/src/DateHandler/_Date_sr.py index 313a7d6f3..6f03f5fac 100644 --- a/src/DateHandler/_Date_sr.py +++ b/src/DateHandler/_Date_sr.py @@ -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.+)\s+(%s)\s+(?P.+)" % - ('|'.join(_span_1),'|'.join(_span_2)), - re.IGNORECASE) + self._span = re.compile("(%s)\s+(?P.+)\s+(%s)\s+(?P.+)" % + ('|'.join(_span_1), '|'.join(_span_2)), + re.IGNORECASE) self._range = re.compile("(%s)\s+(?P.+)\s+(%s)\s+(?P.+)" % - ('|'.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: diff --git a/src/DateHandler/_Date_sv.py b/src/DateHandler/_Date_sv.py index 5b6f51d31..9727569f3 100644 --- a/src/DateHandler/_Date_sv.py +++ b/src/DateHandler/_Date_sv.py @@ -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"", diff --git a/src/DateHandler/_Date_uk.py b/src/DateHandler/_Date_uk.py index 3f6071b04..e6fd27a6b 100644 --- a/src/DateHandler/_Date_uk.py +++ b/src/DateHandler/_Date_uk.py @@ -222,16 +222,14 @@ class DateParserUK(DateParser): _span_1 = [u'з', u'від'] # b.c.e. pattern also have "до" so skip "до н." _span_2 = [u'по', u'до?!\sн\.'] - self._span = re.compile("(%s)\s+(?P.+)\s+(%s)\s+(?P.+)" % - ('|'.join(_span_1), '|'.join(_span_2)), - re.IGNORECASE) _range_1 = [u'між'] _range_2 = [u'і', u'та'] - self._range = re.compile("(%s)\s+(?P.+)\s+(%s)\s+(?P.+)" % - ('|'.join(_range_1), '|'.join(_range_2)), - re.IGNORECASE) - - + self._span = re.compile("(%s)\s+(?P.+)\s+(%s)\s+(?P.+)" % + ('|'.join(_span_1), '|'.join(_span_2)), + re.IGNORECASE) + self._range = re.compile("(%s)\s+(?P.+)\s+(%s)\s+(?P.+)" % + ('|'.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"французький республіканський",