@@ -316,50 +316,6 @@ class Timestamp(_Timestamp):
316
316
317
317
return ts_base
318
318
319
- def __repr__ (self ):
320
- stamp = self ._repr_base
321
- zone = None
322
-
323
- try :
324
- stamp += self .strftime(' %z ' )
325
- if self .tzinfo:
326
- zone = _get_zone(self .tzinfo)
327
- except ValueError :
328
- year2000 = self .replace(year = 2000 )
329
- stamp += year2000.strftime(' %z ' )
330
- if self .tzinfo:
331
- zone = _get_zone(self .tzinfo)
332
-
333
- try :
334
- stamp += zone.strftime(' %% Z' )
335
- except :
336
- pass
337
-
338
- tz = " , tz='{0}'" .format(zone) if zone is not None else " "
339
- offset = " , offset='{0}'" .format(self .offset.freqstr) if self .offset is not None else " "
340
-
341
- return " Timestamp('{stamp}'{tz}{offset})" .format(stamp = stamp, tz = tz, offset = offset)
342
-
343
- @property
344
- def _date_repr (self ):
345
- # Ideal here would be self.strftime("%Y-%m-%d"), but
346
- # the datetime strftime() methods require year >= 1900
347
- return ' %d -%.2d -%.2d ' % (self .year, self .month, self .day)
348
-
349
- @property
350
- def _time_repr (self ):
351
- result = ' %.2d :%.2d :%.2d ' % (self .hour, self .minute, self .second)
352
-
353
- if self .nanosecond != 0 :
354
- result += ' .%.9d ' % (self .nanosecond + 1000 * self .microsecond)
355
- elif self .microsecond != 0 :
356
- result += ' .%.6d ' % self .microsecond
357
-
358
- return result
359
-
360
- @property
361
- def _repr_base (self ):
362
- return ' %s %s ' % (self ._date_repr, self ._time_repr)
363
319
364
320
def _round (self , freq , rounder ):
365
321
@@ -977,6 +933,30 @@ cdef class _Timestamp(datetime):
977
933
self ._assert_tzawareness_compat(other)
978
934
return _cmp_scalar(self .value, ots.value, op)
979
935
936
+ def __repr__ (self ):
937
+ stamp = self ._repr_base
938
+ zone = None
939
+
940
+ try :
941
+ stamp += self .strftime(' %z ' )
942
+ if self .tzinfo:
943
+ zone = _get_zone(self .tzinfo)
944
+ except ValueError :
945
+ year2000 = self .replace(year = 2000 )
946
+ stamp += year2000.strftime(' %z ' )
947
+ if self .tzinfo:
948
+ zone = _get_zone(self .tzinfo)
949
+
950
+ try :
951
+ stamp += zone.strftime(' %% Z' )
952
+ except :
953
+ pass
954
+
955
+ tz = " , tz='{0}'" .format(zone) if zone is not None else " "
956
+ offset = " , offset='{0}'" .format(self .offset.freqstr) if self .offset is not None else " "
957
+
958
+ return " Timestamp('{stamp}'{tz}{offset})" .format(stamp = stamp, tz = tz, offset = offset)
959
+
980
960
cdef bint _compare_outside_nanorange(_Timestamp self , datetime other,
981
961
int op) except - 1 :
982
962
cdef datetime dtval = self .to_datetime()
@@ -1098,6 +1078,27 @@ cdef class _Timestamp(datetime):
1098
1078
out = get_start_end_field(np.array([self .value], dtype = np.int64), field, freqstr, month_kw)
1099
1079
return out[0 ]
1100
1080
1081
+ property _repr_base :
1082
+ def __get__ (self ):
1083
+ return ' %s %s ' % (self ._date_repr, self ._time_repr)
1084
+
1085
+ property _date_repr :
1086
+ def __get__ (self ):
1087
+ # Ideal here would be self.strftime("%Y-%m-%d"), but
1088
+ # the datetime strftime() methods require year >= 1900
1089
+ return ' %d -%.2d -%.2d ' % (self .year, self .month, self .day)
1090
+
1091
+ property _time_repr :
1092
+ def __get__ (self ):
1093
+ result = ' %.2d :%.2d :%.2d ' % (self .hour, self .minute, self .second)
1094
+
1095
+ if self .nanosecond != 0 :
1096
+ result += ' .%.9d ' % (self .nanosecond + 1000 * self .microsecond)
1097
+ elif self .microsecond != 0 :
1098
+ result += ' .%.6d ' % self .microsecond
1099
+
1100
+ return result
1101
+
1101
1102
property asm8 :
1102
1103
def __get__ (self ):
1103
1104
return np.datetime64(self .value, ' ns' )
0 commit comments