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().
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 @@
 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