Skip to content

Commit

Permalink
correctly calculate total years in Duration constructor.
Browse files Browse the repository at this point in the history
  • Loading branch information
ashleysommer committed Oct 15, 2024
1 parent 52eee4c commit 5531b46
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion rdflib/xsd_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
4 changes: 2 additions & 2 deletions test/test_sparql/test_datetime_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
"""
Expand Down

0 comments on commit 5531b46

Please sign in to comment.