示例#1
0
 def __sub__(self, other):
     ret = rd.__sub__(self, other)
     ret.__class__ = relativedelta
     for attr in ('bdays', 'bhours', 'bminutes', 'bseconds'):
         if getattr(self, attr, None) is not None:
             setattr(ret, attr, getattr(self, attr))
             if getattr(other, attr, None) is not None:
                 setattr(ret, attr,
                         getattr(ret, attr) - getattr(other, attr))
     return ret
示例#2
0
 def __sub__(self, other):
     ret = rd.__sub__(self, other)
     ret.__class__ = relativedelta
     for attr in ('bdays', 'bhours', 'bminutes', 'bseconds'):
         if getattr(self, attr, None) is not None:
             setattr(ret, attr, getattr(self, attr))
             if getattr(other, attr, None) is not None:
                 setattr(ret, attr,
                         getattr(ret, attr) - getattr(other, attr))
     return ret