File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -824,9 +824,13 @@ def _add_offset(self, offset: BaseOffset) -> Self:
824824 "s" ,
825825 ]
826826 res_unit = self .unit
827- if hasattr (offset , "offset" ):
828- offset_td = Timedelta (offset .offset )
829- ns = abs (int (offset_td .value )) # Timedelta.value is in nanoseconds
827+ offset_td = getattr (offset , "offset" , None )
828+ if (
829+ offset_td is not None
830+ and isinstance (offset_td , Timedelta )
831+ and offset_td .value != 0
832+ ):
833+ ns = abs (int (offset_td .value ))
830834 if ns == 0 :
831835 eff_unit = self .unit
832836 elif ns % 1_000_000_000 == 0 :
@@ -837,7 +841,6 @@ def _add_offset(self, offset: BaseOffset) -> Self:
837841 eff_unit = "us"
838842 else :
839843 eff_unit = "ns"
840-
841844 idx_self = units .index (self .unit )
842845 idx_eff = units .index (eff_unit )
843846 res_unit = units [min (idx_self , idx_eff )]
You can’t perform that action at this time.
0 commit comments