mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 11:30:18 +00:00
rev2
This commit is contained in:
parent
9a30f4d5b5
commit
36ce3951c6
@ -11,8 +11,8 @@ class timedelta:
|
|||||||
return f"datetime.timedelta({self.days}, {self.seconds})"
|
return f"datetime.timedelta({self.days}, {self.seconds})"
|
||||||
|
|
||||||
def check(self, other, class_type):
|
def check(self, other, class_type):
|
||||||
if not isinstance(other, class_type):
|
if type(other) is not class_type:
|
||||||
raise NotImplementedError("incompatible types / not implemented")
|
return NotImplemented
|
||||||
|
|
||||||
def __eq__(self, other: 'timedelta') -> bool:
|
def __eq__(self, other: 'timedelta') -> bool:
|
||||||
self.check(other, timedelta)
|
self.check(other, timedelta)
|
||||||
@ -55,8 +55,8 @@ class date:
|
|||||||
return date(t.tm_year, t.tm_mon, t.tm_mday)
|
return date(t.tm_year, t.tm_mon, t.tm_mday)
|
||||||
|
|
||||||
def check(self, other, class_type):
|
def check(self, other, class_type):
|
||||||
if not isinstance(other, class_type):
|
if type(other) is not class_type:
|
||||||
raise NotImplementedError("incompatible types / not implemented")
|
return NotImplemented
|
||||||
|
|
||||||
def __eq__(self, other: 'date') -> bool:
|
def __eq__(self, other: 'date') -> bool:
|
||||||
self.check(other, date)
|
self.check(other, date)
|
||||||
@ -106,8 +106,8 @@ class datetime(date):
|
|||||||
return datetime(t.tm_year, t.tm_mon, t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec)
|
return datetime(t.tm_year, t.tm_mon, t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec)
|
||||||
|
|
||||||
def check(self, other, class_type):
|
def check(self, other, class_type):
|
||||||
if not isinstance(other, class_type):
|
if type(other) is not class_type:
|
||||||
raise NotImplementedError("incompatible types / not implemented")
|
return NotImplemented
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"{self.year}-{self.month:02}-{self.day:02} {self.hour:02}:{self.minute:02}:{self.second:02}"
|
return f"{self.year}-{self.month:02}-{self.day:02} {self.hour:02}:{self.minute:02}:{self.second:02}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user