File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #include "Python.h"
2+ #include "_time.h"
3+
4+ /* Exposed in timefuncs.h. */
5+ time_t
6+ _PyTime_DoubleToTimet (double x )
7+ {
8+ time_t result ;
9+ double diff ;
10+
11+ result = (time_t )x ;
12+ /* How much info did we lose? time_t may be an integral or
13+ * floating type, and we don't know which. If it's integral,
14+ * we don't know whether C truncates, rounds, returns the floor,
15+ * etc. If we lost a second or more, the C rounding is
16+ * unreasonable, or the input just doesn't fit in a time_t;
17+ * call it an error regardless. Note that the original cast to
18+ * time_t can cause a C error too, but nothing we can do to
19+ * worm around that.
20+ */
21+ diff = x - (double )result ;
22+ if (diff <= -1.0 || diff >= 1.0 ) {
23+ PyErr_SetString (PyExc_ValueError ,
24+ "timestamp out of range for platform time_t" );
25+ result = (time_t )- 1 ;
26+ }
27+ return result ;
28+ }
Original file line number Diff line number Diff line change 1+ /* XXX: It is probably best to move timefuncs.h content in here, and
2+ remove it but user code may rely on it. */
3+ #include "timefuncs.h"
Original file line number Diff line number Diff line change @@ -90,32 +90,6 @@ static double floattime(void);
9090/* For Y2K check */
9191static PyObject * moddict ;
9292
93- /* Exposed in timefuncs.h. */
94- time_t
95- _PyTime_DoubleToTimet (double x )
96- {
97- time_t result ;
98- double diff ;
99-
100- result = (time_t )x ;
101- /* How much info did we lose? time_t may be an integral or
102- * floating type, and we don't know which. If it's integral,
103- * we don't know whether C truncates, rounds, returns the floor,
104- * etc. If we lost a second or more, the C rounding is
105- * unreasonable, or the input just doesn't fit in a time_t;
106- * call it an error regardless. Note that the original cast to
107- * time_t can cause a C error too, but nothing we can do to
108- * worm around that.
109- */
110- diff = x - (double )result ;
111- if (diff <= -1.0 || diff >= 1.0 ) {
112- PyErr_SetString (PyExc_ValueError ,
113- "timestamp out of range for platform time_t" );
114- result = (time_t )- 1 ;
115- }
116- return result ;
117- }
118-
11993static PyObject *
12094time_time (PyObject * self , PyObject * unused )
12195{
Original file line number Diff line number Diff line change @@ -450,9 +450,9 @@ def detect_modules(self):
450450 depends = ['_math.h' ],
451451 libraries = math_libs ) )
452452 # time operations and variables
453- exts .append ( Extension ('time' , ['timemodule.c' ],
453+ exts .append ( Extension ('time' , ['timemodule.c' , '_time.c' ],
454454 libraries = math_libs ) )
455- exts .append ( Extension ('datetime' , ['datetimemodule.c' , 'timemodule .c' ],
455+ exts .append ( Extension ('datetime' , ['datetimemodule.c' , '_time .c' ],
456456 libraries = math_libs ) )
457457 # fast iterator tools implemented in C
458458 exts .append ( Extension ("itertools" , ["itertoolsmodule.c" ]) )
You can’t perform that action at this time.
0 commit comments