Kaydet (Commit) cd5d765b authored tarafından Victor Stinner's avatar Victor Stinner

cleanup datetime code

remove scories of round half up code and debug code.
üst 7667f581
...@@ -316,13 +316,6 @@ def _divide_and_round(a, b): ...@@ -316,13 +316,6 @@ def _divide_and_round(a, b):
return q return q
def _round_half_up(x):
"""Round to nearest with ties going away from zero."""
if x >= 0.0:
return _math.floor(x + 0.5)
else:
return _math.ceil(x - 0.5)
class timedelta: class timedelta:
"""Represent the difference between two datetime objects. """Represent the difference between two datetime objects.
......
...@@ -679,7 +679,7 @@ class TestTimeDelta(HarmlessMixedComparison, unittest.TestCase): ...@@ -679,7 +679,7 @@ class TestTimeDelta(HarmlessMixedComparison, unittest.TestCase):
us_per_day = us_per_hour * 24 us_per_day = us_per_hour * 24
eq(td(days=.4/us_per_day), td(0)) eq(td(days=.4/us_per_day), td(0))
eq(td(hours=.2/us_per_hour), td(0)) eq(td(hours=.2/us_per_hour), td(0))
eq(td(days=.4/us_per_day, hours=.2/us_per_hour), td(microseconds=1), td) eq(td(days=.4/us_per_day, hours=.2/us_per_hour), td(microseconds=1))
eq(td(days=-.4/us_per_day), td(0)) eq(td(days=-.4/us_per_day), td(0))
eq(td(hours=-.2/us_per_hour), td(0)) eq(td(hours=-.2/us_per_hour), td(0))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment