diff options
author | Alexander Belopolsky <alexander.belopolsky@gmail.com> | 2010-08-05 17:34:27 (GMT) |
---|---|---|
committer | Alexander Belopolsky <alexander.belopolsky@gmail.com> | 2010-08-05 17:34:27 (GMT) |
commit | 6fc4ade2bb44a176555703ebc2dbfb54b57e1148 (patch) | |
tree | c52aa91d4f9e35bb2850ea2aea673e56eabc4ee6 /Modules/_datetimemodule.c | |
parent | 1c5471f319a4e5c7bbb56c7ae349b5fe455dc857 (diff) | |
download | cpython-6fc4ade2bb44a176555703ebc2dbfb54b57e1148.zip cpython-6fc4ade2bb44a176555703ebc2dbfb54b57e1148.tar.gz cpython-6fc4ade2bb44a176555703ebc2dbfb54b57e1148.tar.bz2 |
Issue #9079: Added _PyTime_gettimeofday(_PyTime_timeval *tp) to C API
exposed in Python.h. This function is similar to POSIX
gettimeofday(struct timeval *tp), but available on platforms without
gettimeofday().
Diffstat (limited to 'Modules/_datetimemodule.c')
-rw-r--r-- | Modules/_datetimemodule.c | 33 |
1 files changed, 3 insertions, 30 deletions
diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c index b2505d1..192b1ea 100644 --- a/Modules/_datetimemodule.c +++ b/Modules/_datetimemodule.c @@ -8,7 +8,7 @@ #include <time.h> -#include "timefuncs.h" +#include "_time.h" /* Differentiate between building the core module and building extension * modules. @@ -4166,37 +4166,10 @@ datetime_from_timestamp(PyObject *cls, TM_FUNC f, double timestamp, static PyObject * datetime_best_possible(PyObject *cls, TM_FUNC f, PyObject *tzinfo) { -#ifdef HAVE_GETTIMEOFDAY - struct timeval t; - -#ifdef GETTIMEOFDAY_NO_TZ - gettimeofday(&t); -#else - gettimeofday(&t, (struct timezone *)NULL); -#endif + _PyTime_timeval t; + _PyTime_gettimeofday(&t); return datetime_from_timet_and_us(cls, f, t.tv_sec, (int)t.tv_usec, tzinfo); - -#else /* ! HAVE_GETTIMEOFDAY */ - /* No flavor of gettimeofday exists on this platform. Python's - * time.time() does a lot of other platform tricks to get the - * best time it can on the platform, and we're not going to do - * better than that (if we could, the better code would belong - * in time.time()!) We're limited by the precision of a double, - * though. - */ - PyObject *time; - double dtime; - - time = time_time(); - if (time == NULL) - return NULL; - dtime = PyFloat_AsDouble(time); - Py_DECREF(time); - if (dtime == -1.0 && PyErr_Occurred()) - return NULL; - return datetime_from_timestamp(cls, f, dtime, tzinfo); -#endif /* ! HAVE_GETTIMEOFDAY */ } /* Return best possible local time -- this isn't constrained by the |