@@ -976,11 +976,10 @@ cdef class _Timestamp(datetime):
976
976
pass
977
977
978
978
tz = " , tz='{0}'" .format(zone) if zone is not None else " "
979
- freq = " , freq='{0}'" .format(
980
- self .freq.freqstr) if self .freq is not None else " "
979
+ freq = " " if self .freq is None else " , freq='{0}'" .format(self .freqstr)
981
980
982
- return " Timestamp('{stamp}'{tz}{freq})" .format(
983
- stamp = stamp, tz = tz, freq = freq)
981
+ return " Timestamp('{stamp}'{tz}{freq})" .format(stamp = stamp,
982
+ tz = tz, freq = freq)
984
983
985
984
cdef bint _compare_outside_nanorange(_Timestamp self , datetime other,
986
985
int op) except - 1 :
@@ -1059,11 +1058,13 @@ cdef class _Timestamp(datetime):
1059
1058
return Timestamp((self .freq * other).apply(self ), freq = self .freq)
1060
1059
1061
1060
elif PyDelta_Check(other) or hasattr (other, ' delta' ):
1061
+ # delta --> offsets.Tick
1062
1062
nanos = delta_to_nanoseconds(other)
1063
1063
result = Timestamp(self .value + nanos,
1064
1064
tz = self .tzinfo, freq = self .freq)
1065
1065
if getattr (other, ' normalize' , False ):
1066
- result = Timestamp(normalize_date(result))
1066
+ # DateOffset
1067
+ result = result.normalize()
1067
1068
return result
1068
1069
1069
1070
# index/series like
@@ -1153,42 +1154,43 @@ cdef class _Timestamp(datetime):
1153
1154
field, freqstr, month_kw)
1154
1155
return out[0 ]
1155
1156
1156
- property _repr_base :
1157
- def __get__ (self ):
1158
- return ' %s %s ' % (self ._date_repr, self ._time_repr)
1157
+ @property
1158
+ def _repr_base (self ):
1159
+ return ' {date} {time}' .format(date = self ._date_repr,
1160
+ time = self ._time_repr)
1159
1161
1160
- property _date_repr :
1161
- def __get__ (self ):
1162
- # Ideal here would be self.strftime("%Y-%m-%d"), but
1163
- # the datetime strftime() methods require year >= 1900
1164
- return ' %d -%.2d -%.2d ' % (self .year, self .month, self .day)
1162
+ @ property
1163
+ def _date_repr (self ):
1164
+ # Ideal here would be self.strftime("%Y-%m-%d"), but
1165
+ # the datetime strftime() methods require year >= 1900
1166
+ return ' %d -%.2d -%.2d ' % (self .year, self .month, self .day)
1165
1167
1166
- property _time_repr :
1167
- def __get__ (self ):
1168
- result = ' %.2d :%.2d :%.2d ' % (self .hour, self .minute, self .second)
1168
+ @ property
1169
+ def _time_repr (self ):
1170
+ result = ' %.2d :%.2d :%.2d ' % (self .hour, self .minute, self .second)
1169
1171
1170
- if self .nanosecond != 0 :
1171
- result += ' .%.9d ' % (self .nanosecond + 1000 * self .microsecond)
1172
- elif self .microsecond != 0 :
1173
- result += ' .%.6d ' % self .microsecond
1172
+ if self .nanosecond != 0 :
1173
+ result += ' .%.9d ' % (self .nanosecond + 1000 * self .microsecond)
1174
+ elif self .microsecond != 0 :
1175
+ result += ' .%.6d ' % self .microsecond
1174
1176
1175
- return result
1177
+ return result
1176
1178
1177
- property _short_repr :
1178
- def __get__ (self ):
1179
- # format a Timestamp with only _date_repr if possible
1180
- # otherwise _repr_base
1181
- if (self .hour == 0 and
1182
- self .minute == 0 and
1183
- self .second == 0 and
1184
- self .microsecond == 0 and
1185
- self .nanosecond == 0 ):
1186
- return self ._date_repr
1187
- return self ._repr_base
1188
-
1189
- property asm8 :
1190
- def __get__ (self ):
1191
- return np.datetime64(self .value, ' ns' )
1179
+ @ property
1180
+ def _short_repr (self ):
1181
+ # format a Timestamp with only _date_repr if possible
1182
+ # otherwise _repr_base
1183
+ if (self .hour == 0 and
1184
+ self .minute == 0 and
1185
+ self .second == 0 and
1186
+ self .microsecond == 0 and
1187
+ self .nanosecond == 0 ):
1188
+ return self ._date_repr
1189
+ return self ._repr_base
1190
+
1191
+ @ property
1192
+ def asm8 (self ):
1193
+ return np.datetime64(self .value, ' ns' )
1192
1194
1193
1195
def timestamp (self ):
1194
1196
""" Return POSIX timestamp as float."""
0 commit comments