summaryrefslogtreecommitdiffstats
path: root/Modules/_datetimemodule.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2015-09-08 23:02:23 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2015-09-08 23:02:23 (GMT)
commit7667f58151d5efbbae4f0b1d7178f99dad0d74c0 (patch)
tree99928f745f6377adbf42d8892f30ec1de75a2559 /Modules/_datetimemodule.c
parent69cc487df42d9064a74551ae26a8c115dade3e3a (diff)
downloadcpython-7667f58151d5efbbae4f0b1d7178f99dad0d74c0.zip
cpython-7667f58151d5efbbae4f0b1d7178f99dad0d74c0.tar.gz
cpython-7667f58151d5efbbae4f0b1d7178f99dad0d74c0.tar.bz2
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.
Diffstat (limited to 'Modules/_datetimemodule.c')
-rw-r--r--Modules/_datetimemodule.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c
index 24e83d3..bbc51c6 100644
--- a/Modules/_datetimemodule.c
+++ b/Modules/_datetimemodule.c
@@ -4103,7 +4103,7 @@ datetime_from_timestamp(PyObject *cls, TM_FUNC f, PyObject *timestamp,
long us;
if (_PyTime_ObjectToTimeval(timestamp,
- &timet, &us, _PyTime_ROUND_HALF_UP) == -1)
+ &timet, &us, _PyTime_ROUND_HALF_EVEN) == -1)
return NULL;
return datetime_from_timet_and_us(cls, f, timet, (int)us, tzinfo);