@@ -45,19 +45,11 @@ cdef double NaN = <double> np.NaN
4545cdef double nan = NaN
4646cdef double NAN = nan
4747
48- from datetime import datetime as pydatetime
49-
5048# this is our tseries.pxd
5149from datetime cimport (
5250 get_timedelta64_value, get_datetime64_value,
5351 npy_timedelta, npy_datetime,
5452 PyDateTime_Check, PyDate_Check, PyTime_Check, PyDelta_Check,
55- PyDateTime_GET_YEAR,
56- PyDateTime_GET_MONTH,
57- PyDateTime_GET_DAY,
58- PyDateTime_DATE_GET_HOUR,
59- PyDateTime_DATE_GET_MINUTE,
60- PyDateTime_DATE_GET_SECOND,
6153 PyDateTime_IMPORT)
6254
6355
@@ -132,61 +124,6 @@ def memory_usage_of_objects(ndarray[object, ndim=1] arr):
132124 s += arr[i].__sizeof__()
133125 return s
134126
135- # ----------------------------------------------------------------------
136- # datetime / io related
137-
138- cdef int _EPOCH_ORD = 719163
139-
140- from datetime import date as pydate
141-
142- cdef inline int64_t gmtime(object date):
143- cdef int y, m, d, h, mn, s, days
144-
145- y = PyDateTime_GET_YEAR(date)
146- m = PyDateTime_GET_MONTH(date)
147- d = PyDateTime_GET_DAY(date)
148- h = PyDateTime_DATE_GET_HOUR(date)
149- mn = PyDateTime_DATE_GET_MINUTE(date)
150- s = PyDateTime_DATE_GET_SECOND(date)
151-
152- days = pydate(y, m, 1 ).toordinal() - _EPOCH_ORD + d - 1
153- return ((< int64_t> (((days * 24 + h) * 60 + mn))) * 60 + s) * 1000
154-
155-
156- cpdef object to_datetime(int64_t timestamp):
157- return pydatetime.utcfromtimestamp(timestamp / 1000.0 )
158-
159-
160- cpdef object to_timestamp(object dt):
161- return gmtime(dt)
162-
163-
164- def array_to_timestamp (ndarray[object , ndim = 1 ] arr):
165- cdef int i, n
166- cdef ndarray[int64_t, ndim= 1 ] result
167-
168- n = len (arr)
169- result = np.empty(n, dtype = np.int64)
170-
171- for i from 0 <= i < n:
172- result[i] = gmtime(arr[i])
173-
174- return result
175-
176-
177- def time64_to_datetime (ndarray[int64_t , ndim = 1 ] arr):
178- cdef int i, n
179- cdef ndarray[object , ndim= 1 ] result
180-
181- n = len (arr)
182- result = np.empty(n, dtype = object )
183-
184- for i from 0 <= i < n:
185- result[i] = to_datetime(arr[i])
186-
187- return result
188-
189-
190127# ----------------------------------------------------------------------
191128# isnull / notnull related
192129
0 commit comments