Issue #23517: fromtimestamp() and utcfromtimestamp() methods of

datetime.datetime now round microseconds to nearest with ties going away from
zero (ROUND_HALF_UP), as Python 2 and Python older than 3.3, instead of
rounding towards -Infinity (ROUND_FLOOR).
This commit is contained in:
Victor Stinner 2015-09-03 09:06:44 +02:00
parent 0fa5ef72b7
commit 2ec5bd6fb2
4 changed files with 14 additions and 8 deletions

View file

@ -4078,7 +4078,7 @@ datetime_from_timestamp(PyObject *cls, TM_FUNC f, PyObject *timestamp,
long us;
if (_PyTime_ObjectToTimeval(timestamp,
&timet, &us, _PyTime_ROUND_FLOOR) == -1)
&timet, &us, _PyTime_ROUND_HALF_UP) == -1)
return NULL;
return datetime_from_timet_and_us(cls, f, timet, (int)us, tzinfo);