diff --git a/gramps/gen/datehandler/_date_ru.py b/gramps/gen/datehandler/_date_ru.py index 87d46cf54..04c5af603 100644 --- a/gramps/gen/datehandler/_date_ru.py +++ b/gramps/gen/datehandler/_date_ru.py @@ -130,12 +130,33 @@ class DateDisplayRU(DateDisplay): else: return self.format_long_month_year(date_val[1], year, inflect, long_months) + elif date_val[1] == 0: # month is zero but day is not (see 8477) + return self.display_iso(date_val) else: return "{day:d} {long_month.f[Р]} {year}".format( day = date_val[0], long_month = long_months[date_val[1]], year = year) + def dd_dformat05(self, date_val, inflect, short_months): + """ + day month_abbreviation year -- for Russian locale + """ + year = self._slash_year(date_val[2], date_val[3]) + if date_val[0] == 0: + if date_val[1] == 0: + return year + else: + return self.format_short_month_year(date_val[1], year, + inflect, short_months) + elif date_val[1] == 0: # month is zero but day is not (see 8477) + return self.display_iso(date_val) + else: + return "{day:d} {short_month.f[Р]} {year}".format( + day = date_val[0], + short_month = short_months[date_val[1]], + year = year) + #------------------------------------------------------------------------- # # Register classes diff --git a/gramps/gen/datehandler/test/datedisplay_test.py b/gramps/gen/datehandler/test/datedisplay_test.py index 1581242e7..005f53749 100644 --- a/gramps/gen/datehandler/test/datedisplay_test.py +++ b/gramps/gen/datehandler/test/datedisplay_test.py @@ -66,16 +66,30 @@ class DateDisplayInflectionsTestRU(DateDisplayTest): self.assertIn(month_lexeme.f[inflection], self.dd.display(date)) - def test_month_only_date_nominative(self): - for qual in (Date.QUAL_NONE, Date.QUAL_ESTIMATED, Date.QUAL_CALCULATED): - d1945may = Date(1945, 5, 0) - d1945may.set_quality(qual) - self.assertInflectionInDate('И', d1945may) + def test_month_only_date_nominative_quality_none(self): + d1945may = Date(1945, 5, 0) + d1945may.set_quality(Date.QUAL_NONE) + self.assertInflectionInDate('И', d1945may) + + def test_month_only_date_nominative_quality_estimated(self): + d1945may = Date(1945, 5, 0) + d1945may.set_quality(Date.QUAL_ESTIMATED) + self.assertInflectionInDate('Т', d1945may) + + def test_month_only_date_nominative_quality_calculated(self): + d1945may = Date(1945, 5, 0) + d1945may.set_quality(Date.QUAL_CALCULATED) + self.assertInflectionInDate('И', d1945may) def test_day_month_date_genitive(self): d1945may9 = Date(1945, 5, 9) self.assertInflectionInDate('Р', d1945may9) + def test_day_month_date_genitiive_quality_estimated(self): + d1945may9 = Date(1945, 5, 9) + d1945may9.set_quality(Date.QUAL_ESTIMATED) + self.assertInflectionInDate('Р', d1945may9) + def test_before_month_only_date_genitive(self): d1945may = Date(1945, 5, 0) d1945may.set_modifier(Date.MOD_BEFORE) @@ -86,6 +100,26 @@ class DateDisplayInflectionsTestRU(DateDisplayTest): # will be the same! self.assertIn("до мая", self.dd.display(d1945may)) + def test_after_month_only_date_genitive(self): + d1945may = Date(1945, 5, 0) + d1945may.set_modifier(Date.MOD_AFTER) + # TODO hardwired magic numbers! Bad API smell. + for inflecting_format in (3,4): + self.dd.set_format(inflecting_format) +# this depends on the fact that in Russian the short and long forms for May +# will be the same! + self.assertIn("после мая", self.dd.display(d1945may)) + + def test_about_month_only_date_genitive(self): + d1945may = Date(1945, 5, 0) + d1945may.set_modifier(Date.MOD_ABOUT) + # TODO hardwired magic numbers! Bad API smell. + for inflecting_format in (3,4): + self.dd.set_format(inflecting_format) +# this depends on the fact that in Russian the short and long forms for May +# will be the same! + self.assertIn("около мая", self.dd.display(d1945may)) + def test_between_month_only_dates_ablative(self): b1945may_1946may = Date() b1945may_1946may.set(