conversion.pxd 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. from cpython.datetime cimport (
  2. datetime,
  3. tzinfo,
  4. )
  5. from numpy cimport (
  6. int32_t,
  7. int64_t,
  8. ndarray,
  9. )
  10. from pandas._libs.tslibs.np_datetime cimport (
  11. NPY_DATETIMEUNIT,
  12. npy_datetimestruct,
  13. )
  14. from pandas._libs.tslibs.timestamps cimport _Timestamp
  15. from pandas._libs.tslibs.timezones cimport tz_compare
  16. cdef class _TSObject:
  17. cdef readonly:
  18. npy_datetimestruct dts # npy_datetimestruct
  19. int64_t value # numpy dt64
  20. tzinfo tzinfo
  21. bint fold
  22. NPY_DATETIMEUNIT creso
  23. cdef int64_t ensure_reso(self, NPY_DATETIMEUNIT creso, str val=*) except? -1
  24. cdef _TSObject convert_to_tsobject(object ts, tzinfo tz, str unit,
  25. bint dayfirst, bint yearfirst,
  26. int32_t nanos=*)
  27. cdef _TSObject convert_datetime_to_tsobject(datetime ts, tzinfo tz,
  28. int32_t nanos=*,
  29. NPY_DATETIMEUNIT reso=*)
  30. cdef _TSObject convert_str_to_tsobject(str ts, tzinfo tz, str unit,
  31. bint dayfirst=*,
  32. bint yearfirst=*)
  33. cdef int64_t get_datetime64_nanos(object val, NPY_DATETIMEUNIT reso) except? -1
  34. cpdef datetime localize_pydatetime(datetime dt, tzinfo tz)
  35. cdef int64_t cast_from_unit(object ts, str unit, NPY_DATETIMEUNIT out_reso=*) except? -1
  36. cpdef (int64_t, int) precision_from_unit(str unit, NPY_DATETIMEUNIT out_reso=*)
  37. cdef maybe_localize_tso(_TSObject obj, tzinfo tz, NPY_DATETIMEUNIT reso)
  38. cdef tzinfo convert_timezone(
  39. tzinfo tz_in,
  40. tzinfo tz_out,
  41. bint found_naive,
  42. bint found_tz,
  43. bint utc_convert,
  44. )
  45. cdef int64_t parse_pydatetime(
  46. datetime val,
  47. npy_datetimestruct *dts,
  48. bint utc_convert,
  49. ) except? -1