Changeset 5328:7a4d437f9497 in livinglogic.python.xist

Show
Ignore:
Timestamp:
02/09/13 11:26:00 (6 years ago)
Author:
Walter Doerwald <walter@…>
Branch:
default
Message:

Add support for monthdelta/monthdelta and monthdelta//monthdelta.

Files:
2 modified

Legend:

Unmodified
Added
Removed
  • src/ll/misc.py

    r5241 r5328  
    830830 
    831831    def __floordiv__(self, other): 
    832         if isinstance(other, int) and not isinstance(other, monthdelta): 
     832        if isinstance(other, int): 
    833833            return monthdelta(self.months//other) 
     834        elif isinstance(other, monthdelta): 
     835            return self.months//other.months 
     836        else: 
     837            return NotImplemented 
     838 
     839    def __truediv__(self, other): 
     840        if isinstance(other, monthdelta): 
     841            return self.months/other.months 
    834842        else: 
    835843            return NotImplemented 
  • test/test_ul4.py

    r5322 r5328  
    10071007    assert "12:00:00" == r(code, x=datetime.timedelta(4), y=8) 
    10081008    assert "0:00:00.500000" == r(code, x=datetime.timedelta(0, 4), y=8) 
     1009    assert 2.0 == eval(r(code, x=datetime.timedelta(4), y=datetime.timedelta(2))) 
     1010    assert 2.0 == eval(r(code, x=misc.monthdelta(4), y=misc.monthdelta(2))) 
    10091011 
    10101012