diff --git a/rdflib/xsd_datetime.py b/rdflib/xsd_datetime.py index 44af2172d..a5d08c3b4 100644 --- a/rdflib/xsd_datetime.py +++ b/rdflib/xsd_datetime.py @@ -129,7 +129,7 @@ def __init__( years = Decimal(str(years)) new_years, months = fquotmod(months, 0, 12) self.months = months - self.years = Decimal(new_years) + self.years = Decimal(years+new_years) self.tdelta = timedelta( days, seconds, microseconds, milliseconds, minutes, hours, weeks ) diff --git a/test/test_sparql/test_datetime_processing.py b/test/test_sparql/test_datetime_processing.py index c934e9543..7fd0b2a6c 100644 --- a/test/test_sparql/test_datetime_processing.py +++ b/test/test_sparql/test_datetime_processing.py @@ -94,8 +94,8 @@ def test_datetime_duration_subs(): SELECT (?d - ?duration AS ?next_year) WHERE { VALUES (?duration ?d) { - ("P1Y"^^xsd:yearMonthDuration"2019-05-28T12:14:45Z"^^xsd:dateTime) - ("P1Y"^^xsd:yearMonthDuration"2019-05-28"^^xsd:date) + ("P1Y"^^xsd:yearMonthDuration "2019-05-28T12:14:45Z"^^xsd:dateTime) + ("P1Y"^^xsd:yearMonthDuration "2019-05-28"^^xsd:date) } } """