@@ -389,7 +389,11 @@ cdef class _Timestamp(datetime):
389
389
390
390
if isinstance (other, _Timestamp):
391
391
ots = other
392
- elif isinstance (other, datetime):
392
+ elif type (other) is datetime:
393
+ if self .nanosecond == 0 :
394
+ val = self .to_datetime()
395
+ return PyObject_RichCompareBool(val, other, op)
396
+
393
397
try :
394
398
ots = Timestamp(other)
395
399
except ValueError :
@@ -458,10 +462,14 @@ cdef class _Timestamp(datetime):
458
462
raise Exception (' Cannot compare tz-naive and tz-aware timestamps' )
459
463
460
464
cpdef to_datetime(self ):
461
- return datetime(self .year, self .month, self .day,
462
- self .hour, self .minute, self .second,
463
- self .microsecond, tzinfo = self .tzinfo)
464
-
465
+ cdef:
466
+ pandas_datetimestruct dts
467
+ _TSObject ts
468
+ ts = convert_to_tsobject(self , self .tzinfo)
469
+ dts = ts.dts
470
+ return datetime(dts.year, dts.month, dts.day,
471
+ dts.hour, dts.min, dts.sec,
472
+ dts.us, ts.tzinfo)
465
473
466
474
def __add__ (self , other ):
467
475
if is_integer_object(other):
@@ -786,7 +794,7 @@ def array_to_datetime(ndarray[object] values, raise_=False, dayfirst=False,
786
794
iresult = result.view(' i8' )
787
795
for i in range (n):
788
796
val = values[i]
789
- if util._checknull(val):
797
+ if util._checknull(val) or val is NaT :
790
798
iresult[i] = iNaT
791
799
elif PyDateTime_Check(val):
792
800
if val.tzinfo is not None :
0 commit comments