Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Bug0013415 and 0013423 #1772

Open
wants to merge 3 commits into
base: maintenance/gramps52
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 12 additions & 15 deletions gramps/gen/lib/date.py
Original file line number Diff line number Diff line change
Expand Up @@ -1757,15 +1757,7 @@ def set(
self.calendar = calendar
self.dateval = value
self.set_new_year(newyear)
year, month, day = self._zero_adjust_ymd(
value[Date._POS_YR], value[Date._POS_MON], value[Date._POS_DAY]
)

if year == month == day == 0:
self.sortval = 0
else:
func = Date._calendar_convert[calendar]
self.sortval = func(year, month, day)
self._calc_sort_value()

if self.get_slash() and self.get_calendar() != Date.CAL_JULIAN:
self.set_calendar(Date.CAL_JULIAN)
Expand Down Expand Up @@ -1840,14 +1832,19 @@ def _calc_sort_value(self):
"""
Calculate the numerical sort value associated with the date.
"""
year, month, day = self._zero_adjust_ymd(
self.dateval[Date._POS_YR],
self.dateval[Date._POS_MON],
self.dateval[Date._POS_DAY],
)
if year == month == 0 and day == 0:
if (
self.dateval[Date._POS_YR]
== self.dateval[Date._POS_MON]
== self.dateval[Date._POS_DAY]
== 0
):
self.sortval = 0
else:
year, month, day = self._zero_adjust_ymd(
self.dateval[Date._POS_YR],
self.dateval[Date._POS_MON],
self.dateval[Date._POS_DAY],
)
func = Date._calendar_convert[self.calendar]
self.sortval = func(year, month, day)

Expand Down
16 changes: 8 additions & 8 deletions gramps/gen/lib/test/date_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ def test_non_gregorian(self):

@unittest.skipUnless(
ENGLISH_DATE_HANDLER,
"This test of Date() matching logic can only run in English locale.",
"This test of Date() matching logic can only run in US-English locale.",
)
class MatchDateTest(BaseDateTest):
"""
Expand Down Expand Up @@ -635,7 +635,7 @@ def _get_date(self, value):
# -------------------------------------------------------------------------
@unittest.skipUnless(
ENGLISH_DATE_HANDLER,
"This test of Date() matching logic can only run in English locale.",
"This test of Date() matching logic can only run in US-English locale.",
)
class DateComparisonTest(BaseDateTest):
"""
Expand Down Expand Up @@ -1010,7 +1010,7 @@ def test_comparison(self):
# -------------------------------------------------------------------------
@unittest.skipUnless(
ENGLISH_DATE_HANDLER,
"This test of Date() matching logic can only run in English locale.",
"This test of Date() matching logic can only run in US-English locale.",
)
class AgeTest(BaseDateTest):
"""
Expand Down Expand Up @@ -1055,11 +1055,11 @@ class AgeTest(BaseDateTest):
"2000",
"40 years",
),
("", "1760", "greater than 110 years"),
("", "1960", "greater than 110 years"),
("", "2020", "greater than 110 years"),
("", "3020", "greater than 110 years"),
("2000", "", "(1999 years)"),
("", "1760", "unknown"),
("", "1960", "unknown"),
("", "2020", "unknown"),
("", "3020", "unknown"),
("2000", "", "unknown"),
]

def convert_to_date(self, d):
Expand Down