[Python-checkins] cpython: Issue #22117: Fix rounding of fromtimestamp() methods of datetime.datetime and

victor.stinner python-checkins at python.org
Mon Mar 30 01:11:30 CEST 2015


https://hg.python.org/cpython/rev/6bae19f4e7b2
changeset:   95261:6bae19f4e7b2
parent:      95259:c26b4b85dfc4
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Mon Mar 30 01:10:14 2015 +0200
summary:
  Issue #22117: Fix rounding of fromtimestamp() methods of datetime.datetime and
datetime.time: round towards minus infinity ("floor") instead of rounding
towards zero ("down").

files:
  Modules/_datetimemodule.c |  5 +++--
  1 files changed, 3 insertions(+), 2 deletions(-)


diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c
--- a/Modules/_datetimemodule.c
+++ b/Modules/_datetimemodule.c
@@ -2463,7 +2463,7 @@
     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 @@
     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);
 

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


More information about the Python-checkins mailing list