kopia lustrzana https://github.com/micropython/micropython-lib
datetime: Avoid float.as_integer_ratio().
MicroPython doesn't have it, so implement equivalent (+/- rounding errors) arithmetics.pull/234/merge
rodzic
1bde1058ce
commit
fe2b6d473a
|
@ -505,8 +505,10 @@ class timedelta:
|
|||
self._seconds * other,
|
||||
self._microseconds * other)
|
||||
if isinstance(other, float):
|
||||
a, b = other.as_integer_ratio()
|
||||
return self * a / b
|
||||
#a, b = other.as_integer_ratio()
|
||||
#return self * a / b
|
||||
usec = self._to_microseconds()
|
||||
return timedelta(0, 0, round(usec * other))
|
||||
return NotImplemented
|
||||
|
||||
__rmul__ = __mul__
|
||||
|
@ -533,8 +535,9 @@ class timedelta:
|
|||
if isinstance(other, int):
|
||||
return timedelta(0, 0, usec / other)
|
||||
if isinstance(other, float):
|
||||
a, b = other.as_integer_ratio()
|
||||
return timedelta(0, 0, b * usec / a)
|
||||
# a, b = other.as_integer_ratio()
|
||||
# return timedelta(0, 0, b * usec / a)
|
||||
return timedelta(0, 0, round(usec / other))
|
||||
|
||||
def __mod__(self, other):
|
||||
if isinstance(other, timedelta):
|
||||
|
|
Ładowanie…
Reference in New Issue