-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
remove datetime.pxd #18654
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
remove datetime.pxd #18654
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
# -*- coding: utf-8 -*- | ||
# cython: profile=False | ||
|
||
from cpython cimport Py_EQ, Py_NE, Py_GE, Py_GT, Py_LT, Py_LE | ||
from cpython cimport (Py_EQ, Py_NE, Py_GE, Py_GT, Py_LT, Py_LE, | ||
PyUnicode_Check, PyUnicode_AsASCIIString) | ||
|
||
from cpython.datetime cimport (datetime, date, | ||
PyDateTime_IMPORT, | ||
|
@@ -33,6 +34,11 @@ cdef extern from "../src/datetime/np_datetime.h": | |
|
||
pandas_datetimestruct _NS_MIN_DTS, _NS_MAX_DTS | ||
|
||
cdef extern from "../src/datetime/np_datetime_strings.h": | ||
int parse_iso_8601_datetime(char *str, int len, | ||
pandas_datetimestruct *out, | ||
int *out_local, int *out_tzoffset) | ||
|
||
# ---------------------------------------------------------------------- | ||
# numpy object inspection | ||
|
||
|
@@ -161,3 +167,35 @@ cdef inline int64_t pydate_to_dt64(date val, | |
dts.hour = dts.min = dts.sec = dts.us = 0 | ||
dts.ps = dts.as = 0 | ||
return dtstruct_to_dt64(dts) | ||
|
||
|
||
cdef inline int _string_to_dts(object val, pandas_datetimestruct* dts, | ||
int* out_local, int* out_tzoffset) except? -1: | ||
cdef: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. when you do change this, pls add doc-string (and same below) |
||
int result | ||
char *tmp | ||
|
||
if PyUnicode_Check(val): | ||
val = PyUnicode_AsASCIIString(val) | ||
|
||
tmp = val | ||
result = _cstring_to_dts(tmp, len(val), dts, out_local, out_tzoffset) | ||
|
||
if result == -1: | ||
raise ValueError('Unable to parse %s' % str(val)) | ||
return result | ||
|
||
|
||
cdef inline int _cstring_to_dts(char *val, int length, | ||
pandas_datetimestruct* dts, | ||
int* out_local, int* out_tzoffset) except? -1: | ||
# Note: without this "extra layer" between _string_to_dts | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. have to investigate this, it is pretty weird |
||
# and parse_iso_8601_datetime, calling _string_to_dts raises | ||
# `SystemError: <class 'str'> returned a result with an error set` | ||
# in Python3 | ||
cdef: | ||
int result | ||
|
||
result = parse_iso_8601_datetime(val, length, | ||
dts, out_local, out_tzoffset) | ||
return result |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can deprivatize at some point
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yah I’m currently running asv on a proposed change to string_to_dts that would make to_datetime and Timestamp behavior more similar (or at least make the dissimilarity more obvious)