summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2015-03-28 04:02:39 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2015-03-28 04:02:39 (GMT)
commit02937aab13ecfe1f67b8de48c37412b0328217ec (patch)
treee6ae07581ca459a4b561f479d1610b2c5341fff2 /Modules
parentb3b454407058cd57d8a401a5aeb018d4ccb87616 (diff)
downloadcpython-02937aab13ecfe1f67b8de48c37412b0328217ec.zip
cpython-02937aab13ecfe1f67b8de48c37412b0328217ec.tar.gz
cpython-02937aab13ecfe1f67b8de48c37412b0328217ec.tar.bz2
Issue #22117: Add the new _PyTime_ROUND_FLOOR rounding method for the datetime
module. time.clock_settime() now uses this rounding method instead of _PyTime_ROUND_DOWN to handle correctly dates before 1970.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_testcapimodule.c3
-rw-r--r--Modules/timemodule.c4
2 files changed, 4 insertions, 3 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
index 4503dc3..5c54ad6 100644
--- a/Modules/_testcapimodule.c
+++ b/Modules/_testcapimodule.c
@@ -2634,7 +2634,8 @@ run_in_subinterp(PyObject *self, PyObject *args)
static int
check_time_rounding(int round)
{
- if (round != _PyTime_ROUND_DOWN && round != _PyTime_ROUND_UP) {
+ if (round != _PyTime_ROUND_DOWN && round != _PyTime_ROUND_UP
+ && round != _PyTime_ROUND_FLOOR) {
PyErr_SetString(PyExc_ValueError, "invalid rounding");
return -1;
}
diff --git a/Modules/timemodule.c b/Modules/timemodule.c
index 3178fcb..99e83cc 100644
--- a/Modules/timemodule.c
+++ b/Modules/timemodule.c
@@ -173,7 +173,7 @@ time_clock_settime(PyObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "iO:clock_settime", &clk_id, &obj))
return NULL;
- if (_PyTime_FromSecondsObject(&t, obj, _PyTime_ROUND_DOWN) < 0)
+ if (_PyTime_FromSecondsObject(&t, obj, _PyTime_ROUND_FLOOR) < 0)
return NULL;
if (_PyTime_AsTimespec(t, &tp) == -1)
@@ -322,7 +322,7 @@ parse_time_t_args(PyObject *args, char *format, time_t *pwhen)
whent = time(NULL);
}
else {
- if (_PyTime_ObjectToTime_t(ot, &whent, _PyTime_ROUND_DOWN) == -1)
+ if (_PyTime_ObjectToTime_t(ot, &whent, _PyTime_ROUND_FLOOR) == -1)
return 0;
}
*pwhen = whent;