diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2015-03-30 01:10:14 +0200 |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2015-03-30 01:10:14 +0200 |
commit | e4a994d6171f47ee9ba68ae1484d940349d62564 (patch) | |
tree | 5157522ff66bdf1994acabd0c210ee1a9659b77e | |
parent | dca028b86ade11441554f8cdb9d2ae56c119b413 (diff) | |
download | cpython-git-e4a994d6171f47ee9ba68ae1484d940349d62564.tar.gz |
Issue #22117: Fix rounding of fromtimestamp() methods of datetime.datetime and
datetime.time: round towards minus infinity ("floor") instead of rounding
towards zero ("down").
-rw-r--r-- | Modules/_datetimemodule.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c index c3e54f7af4..ab2acae662 100644 --- a/Modules/_datetimemodule.c +++ b/Modules/_datetimemodule.c @@ -2463,7 +2463,7 @@ date_local_from_object(PyObject *cls, PyObject *obj) struct tm *tm; time_t t; - if (_PyTime_ObjectToTime_t(obj, &t, _PyTime_ROUND_DOWN) == -1) + if (_PyTime_ObjectToTime_t(obj, &t, _PyTime_ROUND_FLOOR) == -1) return NULL; tm = localtime(&t); @@ -4095,7 +4095,8 @@ datetime_from_timestamp(PyObject *cls, TM_FUNC f, PyObject *timestamp, time_t timet; long us; - if (_PyTime_ObjectToTimeval(timestamp, &timet, &us, _PyTime_ROUND_DOWN) == -1) + if (_PyTime_ObjectToTimeval(timestamp, + &timet, &us, _PyTime_ROUND_FLOOR) == -1) return NULL; assert(0 <= us && us <= 999999); |