File tree 1 file changed +9
-7
lines changed
1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ from pandas._libs.tslibs.np_datetime cimport (
32
32
npy_datetimestruct, dtstruct_to_dt64, dt64_to_dtstruct)
33
33
from pandas._libs.tslibs.timezones import UTC
34
34
from pandas._libs.tslibs.tzconversion cimport tz_convert_single
35
+ from pandas._libs.tslibs.c_timestamp cimport _Timestamp
35
36
36
37
37
38
# ---------------------------------------------------------------------
@@ -105,17 +106,18 @@ cdef to_offset(object obj):
105
106
return to_offset(obj)
106
107
107
108
108
- def as_datetime (obj ):
109
- f = getattr (obj, ' to_pydatetime' , None )
110
- if f is not None :
111
- obj = f()
109
+ def as_datetime (obj: datetime ) -> datetime:
110
+ if isinstance(obj , _Timestamp ):
111
+ return obj.to_pydatetime()
112
112
return obj
113
113
114
114
115
- cpdef bint is_normalized(dt):
116
- if ( dt.hour != 0 or dt.minute != 0 or dt.second != 0 or
117
- dt.microsecond ! = 0 or getattr (dt, ' nanosecond ' , 0 ) ! = 0 ):
115
+ cpdef bint is_normalized(datetime dt):
116
+ if dt.hour != 0 or dt.minute != 0 or dt.second != 0 or dt.microsecond ! = 0 :
117
+ # Regardless of whether dt is datetime vs Timestamp
118
118
return False
119
+ if isinstance (dt, _Timestamp):
120
+ return dt.nanosecond == 0
119
121
return True
120
122
121
123
You can’t perform that action at this time.
0 commit comments