Skip to content

Commit 4416be0

Browse files
committed
Add datetime.__rsub__
1 parent 936c18f commit 4416be0

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

graalpython/lib-python/3/datetime.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2219,6 +2219,12 @@ def __sub__(self, other):
22192219
raise TypeError("cannot mix naive and timezone-aware time")
22202220
return base + otoff - myoff
22212221

2222+
# GraalPy change: this was missing, but the C impl has it
2223+
def __rsub__(self, other):
2224+
if isinstance(other, datetime):
2225+
return type(self).__sub__(other, self)
2226+
return NotImplemented
2227+
22222228
def __hash__(self):
22232229
if self._hashcode == -1:
22242230
if self.fold:

0 commit comments

Comments
 (0)