From 7667f58151d5efbbae4f0b1d7178f99dad0d74c0 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 9 Sep 2015 01:02:23 +0200 Subject: Issue #23517: fromtimestamp() and utcfromtimestamp() methods of datetime.datetime now round microseconds to nearest with ties going to nearest even integer (ROUND_HALF_EVEN), as round(float), instead of rounding towards -Infinity (ROUND_FLOOR). pytime API: replace _PyTime_ROUND_HALF_UP with _PyTime_ROUND_HALF_EVEN. Fix also _PyTime_Divide() for negative numbers. _PyTime_AsTimeval_impl() now reuses _PyTime_Divide() instead of reimplementing rounding modes. --- Lib/datetime.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Lib/datetime.py') diff --git a/Lib/datetime.py b/Lib/datetime.py index 3c25ef84c6..3f29bc4b7a 100644 --- a/Lib/datetime.py +++ b/Lib/datetime.py @@ -1380,7 +1380,7 @@ class datetime(date): A timezone info object may be passed in as well. """ frac, t = _math.modf(t) - us = _round_half_up(frac * 1e6) + us = round(frac * 1e6) if us >= 1000000: t += 1 us -= 1000000 -- cgit v1.2.1