@@ -2710,6 +2710,9 @@ def __add__(self, other):
2710
2710
return self .apply (other )
2711
2711
except ApplyTypeError :
2712
2712
return NotImplemented
2713
+ except OverflowError :
2714
+ raise OverflowError ("the add operation between {} and {} "
2715
+ "will overflow" .format (self , other ))
2713
2716
2714
2717
def __eq__ (self , other ):
2715
2718
if isinstance (other , compat .string_types ):
@@ -2748,14 +2751,20 @@ def nanos(self):
2748
2751
2749
2752
def apply (self , other ):
2750
2753
# Timestamp can handle tz and nano sec, thus no need to use apply_wraps
2751
- if isinstance (other , (datetime , np .datetime64 , date )):
2754
+ if isinstance (other , Timestamp ):
2755
+ result = as_timestamp (other ).__add__ (self )
2756
+ if result == NotImplemented :
2757
+ raise OverflowError
2758
+ return result
2759
+ elif isinstance (other , (datetime , np .datetime64 , date )):
2752
2760
return as_timestamp (other ) + self
2761
+
2753
2762
if isinstance (other , timedelta ):
2754
- return other + self .delta
2763
+ return other . __add__ ( self .delta )
2755
2764
elif isinstance (other , type (self )):
2756
2765
return type (self )(self .n + other .n )
2757
- else :
2758
- raise ApplyTypeError ('Unhandled type: %s' % type (other ).__name__ )
2766
+
2767
+ raise ApplyTypeError ('Unhandled type: %s' % type (other ).__name__ )
2759
2768
2760
2769
_prefix = 'undefined'
2761
2770
0 commit comments