@@ -35,18 +35,17 @@ from cython cimport Py_ssize_t
35
35
36
36
37
37
import pytz
38
- UTC = pytz.utc
39
38
40
39
41
40
from tslibs.timedeltas cimport cast_from_unit
42
- from tslibs.timedeltas import Timedelta
41
+ from tslibs.timedeltas import Timedelta, ints_to_pytimedelta # noqa:F841
43
42
from tslibs.timezones cimport (is_utc, is_tzlocal, is_fixed_offset,
44
43
treat_tz_as_pytz, get_dst_info)
45
44
from tslibs.conversion cimport (tz_convert_single, _TSObject,
46
45
convert_datetime_to_tsobject,
47
46
get_datetime64_nanos,
48
47
tz_convert_utc_to_tzlocal)
49
- from tslibs.conversion import tz_convert_single
48
+ from tslibs.conversion import tz_convert_single, normalize_date # noqa:F841
50
49
51
50
from tslibs.nattype import NaT, nat_strings, iNaT
52
51
from tslibs.nattype cimport checknull_with_nat, NPY_NAT
@@ -185,29 +184,6 @@ def ints_to_pydatetime(ndarray[int64_t] arr, tz=None, freq=None,
185
184
return result
186
185
187
186
188
- def ints_to_pytimedelta (ndarray[int64_t] arr , box = False ):
189
- # convert an i8 repr to an ndarray of timedelta or Timedelta (if box ==
190
- # True)
191
-
192
- cdef:
193
- Py_ssize_t i, n = len (arr)
194
- int64_t value
195
- ndarray[object ] result = np.empty(n, dtype = object )
196
-
197
- for i in range (n):
198
-
199
- value = arr[i]
200
- if value == NPY_NAT:
201
- result[i] = NaT
202
- else :
203
- if box:
204
- result[i] = Timedelta(value)
205
- else :
206
- result[i] = timedelta(microseconds = int (value) / 1000 )
207
-
208
- return result
209
-
210
-
211
187
def _test_parse_iso8601 (object ts ):
212
188
"""
213
189
TESTING ONLY: Parse string into Timestamp using iso8601 parser. Used
@@ -740,30 +716,3 @@ cdef inline bint _parse_today_now(str val, int64_t* iresult):
740
716
iresult[0 ] = Timestamp.today().value
741
717
return True
742
718
return False
743
-
744
- # ----------------------------------------------------------------------
745
- # Some general helper functions
746
-
747
-
748
- cpdef normalize_date(object dt):
749
- """
750
- Normalize datetime.datetime value to midnight. Returns datetime.date as a
751
- datetime.datetime at midnight
752
-
753
- Returns
754
- -------
755
- normalized : datetime.datetime or Timestamp
756
- """
757
- if PyDateTime_Check(dt):
758
- if not PyDateTime_CheckExact(dt):
759
- # i.e. a Timestamp object
760
- return dt.replace(hour = 0 , minute = 0 , second = 0 , microsecond = 0 ,
761
- nanosecond = 0 )
762
- else :
763
- # regular datetime object
764
- return dt.replace(hour = 0 , minute = 0 , second = 0 , microsecond = 0 )
765
- # TODO: Make sure DST crossing is handled correctly here
766
- elif PyDate_Check(dt):
767
- return datetime(dt.year, dt.month, dt.day)
768
- else :
769
- raise TypeError (' Unrecognized type: %s ' % type (dt))
0 commit comments