[Python-checkins] cpython: cleanup datetime code

victor.stinner python-checkins at python.org
Wed Sep 9 01:09:41 CEST 2015


https://hg.python.org/cpython/rev/46d812637efd
changeset:   97783:46d812637efd
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Wed Sep 09 01:09:21 2015 +0200
summary:
  cleanup datetime code

remove scories of round half up code and debug code.

files:
  Lib/datetime.py            |  7 -------
  Lib/test/datetimetester.py |  2 +-
  2 files changed, 1 insertions(+), 8 deletions(-)


diff --git a/Lib/datetime.py b/Lib/datetime.py
--- a/Lib/datetime.py
+++ b/Lib/datetime.py
@@ -316,13 +316,6 @@
 
     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:
     """Represent the difference between two datetime objects.
diff --git a/Lib/test/datetimetester.py b/Lib/test/datetimetester.py
--- a/Lib/test/datetimetester.py
+++ b/Lib/test/datetimetester.py
@@ -679,7 +679,7 @@
         us_per_day = us_per_hour * 24
         eq(td(days=.4/us_per_day), 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(hours=-.2/us_per_hour), td(0))

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list