예제 #1
0
    def test_greg_duration_operators(self):
        p = posix_time.ptime( gregorian.date(2001, date_time.Oct, 31), posix_time.hours(5))
        self.failUnless( posix_time.ptime( gregorian.date(2002, date_time.Feb, 28)
                                           , posix_time.hours(5)) 
                         == p + gregorian.months(4) )
        p += gregorian.months(4)
        self.failUnless( posix_time.ptime(gregorian.date(2002, date_time.Feb, 28), posix_time.hours(5)) == p)

        p = posix_time.ptime( gregorian.date(2001, date_time.Oct, 31), posix_time.hours(5))
        self.failUnless( posix_time.ptime(gregorian.date(2001, date_time.Apr, 30), posix_time.hours(5)) 
                         == p - gregorian.months(6))
        p -= gregorian.months(6)
        self.failUnless( posix_time.ptime(gregorian.date(2001, date_time.Apr, 30)
                                          , posix_time.hours(5)) == p)
        
        p = posix_time.ptime(gregorian.date(2001, date_time.Feb, 28), posix_time.hours(5))
        self.failUnless( posix_time.ptime( gregorian.date(2004, date_time.Feb, 29)
                                           , posix_time.hours(5)) 
                         == p + gregorian.years(3))
        p += gregorian.years(3)
        self.failUnless( posix_time.ptime( gregorian.date(2004, date_time.Feb, 29)
                                           , posix_time.hours(5)) 
                         == p )
        
        p = posix_time.ptime(gregorian.date(2000, date_time.Feb, 29), posix_time.hours(5))
        self.failUnless( posix_time.ptime(gregorian.date(1998, date_time.Feb, 28), posix_time.hours(5)) 
                         == p - gregorian.years(2))
        p -= gregorian.years(2)
        self.failUnless( posix_time.ptime(gregorian.date(1998, date_time.Feb, 28), posix_time.hours(5)) 
                         == p)
예제 #2
0
    def test_greg_duration_operators(self):
        p = posix_time.ptime(gregorian.date(2001, date_time.Oct, 31),
                             posix_time.hours(5))
        self.failUnless(
            posix_time.ptime(gregorian.date(2002, date_time.Feb, 28),
                             posix_time.hours(5)) == p + gregorian.months(4))
        p += gregorian.months(4)
        self.failUnless(
            posix_time.ptime(gregorian.date(2002, date_time.Feb, 28),
                             posix_time.hours(5)) == p)

        p = posix_time.ptime(gregorian.date(2001, date_time.Oct, 31),
                             posix_time.hours(5))
        self.failUnless(
            posix_time.ptime(gregorian.date(2001, date_time.Apr, 30),
                             posix_time.hours(5)) == p - gregorian.months(6))
        p -= gregorian.months(6)
        self.failUnless(
            posix_time.ptime(gregorian.date(2001, date_time.Apr, 30),
                             posix_time.hours(5)) == p)

        p = posix_time.ptime(gregorian.date(2001, date_time.Feb, 28),
                             posix_time.hours(5))
        self.failUnless(
            posix_time.ptime(gregorian.date(2004, date_time.Feb, 29),
                             posix_time.hours(5)) == p + gregorian.years(3))
        p += gregorian.years(3)
        self.failUnless(
            posix_time.ptime(gregorian.date(2004, date_time.Feb, 29),
                             posix_time.hours(5)) == p)

        p = posix_time.ptime(gregorian.date(2000, date_time.Feb, 29),
                             posix_time.hours(5))
        self.failUnless(
            posix_time.ptime(gregorian.date(1998, date_time.Feb, 28),
                             posix_time.hours(5)) == p - gregorian.years(2))
        p -= gregorian.years(2)
        self.failUnless(
            posix_time.ptime(gregorian.date(1998, date_time.Feb, 28),
                             posix_time.hours(5)) == p)
예제 #3
0
    def test_greg_durations(self):
        m1 = gregorian.months(5)
        m2 = gregorian.months(3)
        m3 = gregorian.months(1)
        self.failUnless(gregorian.months(8) == m1 + m2)
        m1 += m2
        self.failUnless(gregorian.months(8) == m1)
        self.failUnless(gregorian.months(-5) == m2 - m1)
        m2 -= m1
        self.failUnless(gregorian.months(-5) == m2)

        d1 = gregorian.date(2005, date_time.Jan, 1)

        self.failUnless(
            d1 +
            gregorian.months(-1) == gregorian.date(2004, date_time.Dec, 1))
        d3 = gregorian.date(2005, date_time.Dec, 1)
        self.failUnless(
            d3 -
            gregorian.months(-1) == gregorian.date(2006, date_time.Jan, 1))
        m1 = gregorian.months(5)
        m2 = gregorian.months(3)
        m3 = gregorian.months(10)
        self.failUnless(gregorian.months(15) == m1 * 3)
        m1 *= 3
        self.failUnless(gregorian.months(15) == m1)
        self.failUnless(gregorian.months(12) == m2 * 4)
        self.failUnless(gregorian.months(3) == m3 / 3)
        m3 /= 3
        self.failUnless(gregorian.months(3) == m3)

        m = gregorian.months(-5)
        m_pos = gregorian.months(date_time.pos_infin)
        m_neg = gregorian.months(date_time.neg_infin)
        m_nadt = gregorian.months(date_time.not_a_date_time)
        self.failUnless(m + m_pos == m_pos)
        self.failUnless(m + m_neg == m_neg)
        self.failUnless(m_pos + m_neg == m_nadt)
        self.failUnless(m_neg + m_neg == m_neg)
        self.failUnless(m - m_pos == m_neg)
        self.failUnless(m - m_neg == m_pos)
        self.failUnless(m_pos - m_neg == m_pos)
        self.failUnless(m_pos * -1 == m_neg)
        self.failUnless(m_pos * 0 == m_nadt)
        self.failUnless(m_neg / 3 == m_neg)

        y1 = gregorian.years(2)
        y2 = gregorian.years(4)
        self.failUnless(gregorian.months(27) == m3 + y1)
        m3 += y1
        self.failUnless(gregorian.months(27) == m3)
        self.failUnless(gregorian.months(-21) == m3 - y2)
        m3 -= y2
        self.failUnless(gregorian.months(-21) == m3)

        d = gregorian.date(2001, date_time.Oct, 31)
        self.failUnless(
            gregorian.date(2002, date_time.Feb, 28) == d + gregorian.months(4))
        d += gregorian.months(4)
        self.failUnless(gregorian.date(2002, date_time.Feb, 28) == d)
        d = gregorian.date(2001, date_time.Oct, 31)
        self.failUnless(
            gregorian.date(2001, date_time.Apr, 30) == d - gregorian.months(6))
        d -= gregorian.months(6)
        self.failUnless(gregorian.date(2001, date_time.Apr, 30) == d)

        y1 = gregorian.years(2)
        y2 = gregorian.years(4)
        y3 = gregorian.years(1)
        self.failUnless(gregorian.years(3) == y3 + y1)
        y3 += y1
        self.failUnless(gregorian.years(3) == y3)
        self.failUnless(gregorian.years(-1) == y3 - y2)
        y3 -= y2
        self.failUnless(gregorian.years(-1) == y3)

        y1 = gregorian.years(5)
        y2 = gregorian.years(3)
        y3 = gregorian.years(10)

        self.failUnless(gregorian.years(15) == y1 * 3)
        y1 *= 3
        self.failUnless(gregorian.years(15) == y1)

        self.failUnless(gregorian.years(3) == y3 / 3)
        y3 /= 3
        self.failUnless(gregorian.years(3) == y3)

        m = gregorian.years(15)
        y_pos = gregorian.years(date_time.pos_infin)
        y_neg = gregorian.years(date_time.neg_infin)
        y_nadt = gregorian.years(date_time.not_a_date_time)
        self.failUnless(m + y_pos == y_pos)
        self.failUnless(m + y_neg == y_neg)
        self.failUnless(y_pos + y_neg == y_nadt)
        self.failUnless(y_neg + y_neg == y_neg)
        self.failUnless(m - y_pos == y_neg)
        self.failUnless(m - y_neg == y_pos)
        self.failUnless(y_pos - y_neg == y_pos)
        self.failUnless(y_pos * -1 == y_neg)
        self.failUnless(y_pos * 0 == y_nadt)
        self.failUnless(y_neg / 3 == y_neg)

        m1 = gregorian.months(5)
        m2 = gregorian.months(3)
        self.failUnless(gregorian.months(39) == y2 + m2)
        self.failUnless(gregorian.months(31) == y2 - m1)

        d = gregorian.date(2001, date_time.Feb, 28)
        self.failUnless(
            gregorian.date(2004, date_time.Feb, 29) == d + gregorian.years(3))
        d += gregorian.years(3)
        self.failUnless(gregorian.date(2004, date_time.Feb, 29) == d)

        d = gregorian.date(2000, date_time.Feb, 29)
        self.failUnless(
            gregorian.date(1994, date_time.Feb, 28) == d - gregorian.years(6))
        d -= gregorian.years(6)
        self.failUnless(gregorian.date(1994, date_time.Feb, 28) == d)

        w1 = gregorian.weeks(2)
        w2 = gregorian.weeks(4)
        w3 = gregorian.weeks(1)
        pi = gregorian.weeks(date_time.pos_infin)
        self.failUnless(gregorian.weeks(date_time.pos_infin) == w1 + pi)
        self.failUnless(gregorian.weeks(3) == w3 + w1)
        w3 += w1
        self.failUnless(gregorian.weeks(3) == w3)
        self.failUnless(gregorian.weeks(-1) == w3 - w2)
        w3 -= w2
        self.failUnless(gregorian.weeks(-1) == w3)

        d = gregorian.days(10)
        self.failUnless(gregorian.days(31) == d + gregorian.weeks(3))
        d += gregorian.weeks(3)
        self.failUnless(gregorian.days(31) == d)

        d = gregorian.days(10)
        self.failUnless(gregorian.days(-32) == d - gregorian.weeks(6))
        d -= gregorian.weeks(6)
        self.failUnless(gregorian.days(-32) == d)

        d = gregorian.date(2001, date_time.Feb, 28)
        self.failUnless(
            gregorian.date(2001, date_time.Mar, 21) == d + gregorian.weeks(3))
        d += gregorian.weeks(3)
        self.failUnless(gregorian.date(2001, date_time.Mar, 21) == d)

        d = gregorian.date(2001, date_time.Feb, 28)
        self.failUnless(
            gregorian.date(2001, date_time.Jan, 17) == d - gregorian.weeks(6))
        d -= gregorian.weeks(6)
        self.failUnless(gregorian.date(2001, date_time.Jan, 17) == d)

        d = gregorian.date(2000, date_time.Oct, 31)
        d2 = d + gregorian.months(4) + gregorian.years(2)
        d3 = d + gregorian.years(2) + gregorian.months(4)
        self.failUnless(gregorian.date(2003, date_time.Feb, 28) == d2)
        self.failUnless(gregorian.date(2003, date_time.Feb, 28) == d3)
        m = gregorian.years(2) + gregorian.months(4) - gregorian.months(
            4) - gregorian.years(2)
        self.failUnless(m.number_of_months() == 0)
예제 #4
0
    def test_local_time( self ):
        az_tz = local_time.posix_time_zone("MST-07")
        ny_tz = local_time.posix_time_zone("EST-05EDT,M4.1.0,M10.5.0")
        sydney = local_time.posix_time_zone("EST+10EST,M10.5.0,M3.5.0/03:00")
        null_tz = None
        d = gregorian.date(2003, 12, 20)
        h = posix_time.hours(12)
        t = posix_time.ptime(d,h)
        az_time = local_time.local_date_time(t, az_tz ) 
        
        self.failUnless( az_time.zone().std_zone_abbrev() == "MST") 
        self.failUnless( az_time.zone().base_utc_offset() == posix_time.hours(-7) )
        self.failUnless( az_time.zone().has_dst() == False )
        self.failUnless( az_time.is_dst() == False )
        self.failUnless( az_time.to_string() == "2003-Dec-20 05:00:00 MST" )
        
        az_time2 = local_time.local_date_time(t, az_tz ) 
        
        self.failUnless( az_time2.is_dst() == False )
        self.failUnless( az_time2.to_string() == "2003-Dec-20 05:00:00 MST" )
        self.failUnless( az_time2.zone().has_dst() == False )
        self.failUnless( az_time2.zone().base_utc_offset() == posix_time.hours(-7) )
                
        svpt = posix_time.ptime(date_time.not_a_date_time)
        sv_time = local_time.local_date_time(svpt, ny_tz)
        self.failUnless( sv_time.is_not_a_date_time() )
        self.failUnless( sv_time.to_string() == "not-a-date-time" )
        self.failUnless( sv_time.is_dst() == False )
        sv_time2 = local_time.local_date_time( date_time.pos_infin, None )
        self.failUnless( sv_time2.is_pos_infinity() )
        self.failUnless( sv_time2.to_string() == "+infinity" )
        self.failUnless( sv_time2.is_dst() == False )
        sv_time2 += gregorian.days(12) 
        self.failUnless( sv_time2.is_pos_infinity() )

        sv_time3 = local_time.local_date_time( date_time.max_date_time, ny_tz )
        self.failUnless( sv_time3.to_string() == "9999-Dec-31 18:59:59.999999999 EST" 
                         or sv_time3.to_string() == "9999-Dec-31 18:59:59.999999 EST" )
        
        sv_time4 = local_time.local_date_time(date_time.min_date_time, None)
        self.failUnless( sv_time4.to_string() == "1400-Jan-01 00:00:00 UTC" )
        
        d = gregorian.date(2004, date_time.Apr, 4)
        td = posix_time.time_duration(2,30,0) 
        calcop = local_time.local_date_time(d, td, ny_tz, local_time.local_date_time.NOT_DATE_TIME_ON_ERROR)
        self.failUnless( calcop.is_not_a_date_time() )

        d = gregorian.date(2004, date_time.Apr, 4)
        td = posix_time.time_duration(2,30,0) 
        self.failUnlessRaises( Exception, local_time.local_date_time, d, td, ny_tz, local_time.local_date_time.EXCEPTION_ON_ERROR)
        
        az_time3 = local_time.local_date_time(d, h, az_tz, False)
        self.failUnless( az_time3.zone().std_zone_abbrev() == "MST") 
        self.failUnless( az_time3.zone().base_utc_offset() == posix_time.hours(-7) )
        self.failUnless( az_time3.zone().has_dst() == False )
        self.failUnless( az_time3.is_dst() == False )
        self.failUnless( az_time3.to_string() == "2004-Apr-04 12:00:00 MST" )
        
        null_tz_time = local_time.local_date_time(d, h, null_tz, True)
        
        self.failUnless( null_tz_time.is_dst() == False )
        self.failUnless( null_tz_time.to_string() == "2004-Apr-04 12:00:00 UTC" )
        
        self.failUnlessRaises( Exception
                               , local_time.local_date_time
                               , gregorian.date(2004,date_time.Apr,4)
                               , posix_time.time_duration(2,30,0)
                               , ny_tz
                               , True )
          
        d = gregorian.date(2004, date_time.Apr,4)
        td = posix_time.time_duration(1,15,0) 
        lt1 = local_time.local_date_time(d,td,ny_tz,False)
        lt2 = local_time.local_date_time( posix_time.ptime(d
                                                           , posix_time.time_duration(6,15,0) )
                                          , ny_tz)
        self.failUnless( lt1.utc_time() == lt2.utc_time( ))
        self.failUnless( lt1.is_dst() == False )
        self.failUnless( lt2.is_dst() == False )
        lt1 += posix_time.hours(1)
        lt2 += posix_time.hours(1)
        self.failUnless( lt1.is_dst() == True)
        self.failUnless( lt2.is_dst() == True)
    
        d = gregorian.date(2004,date_time.Oct,31)
        td = posix_time.time_duration(1,15,0) 
        lt1 = local_time.local_date_time(d,td,ny_tz,True)
        lt2 = local_time.local_date_time(posix_time.ptime(d
                                                          , posix_time.time_duration(5,15,0))
                                         , ny_tz)
        self.failUnless( lt1.utc_time() == lt2.utc_time() )
        self.failUnless( lt1.is_dst() == True )
        self.failUnless( lt2.is_dst() == True )
        lt1 += posix_time.hours(1)
        lt2 += posix_time.hours(1)
        self.failUnless( lt1.is_dst() == False )
        self.failUnless( lt2.is_dst() == False )
        
        ny_time = az_time.local_time_in(ny_tz, posix_time.time_duration(0,0,0))
        self.failUnless( ny_time.zone().std_zone_abbrev() == "EST" )
        self.failUnless( ny_time.zone().base_utc_offset() == posix_time.hours(-5) )
        self.failUnless( ny_time.zone().has_dst() == True )
        self.failUnless( ny_time.to_string() == "2003-Dec-20 07:00:00 EST" )
        ny_time += posix_time.hours(3)
        self.failUnless( ny_time.to_string() == "2003-Dec-20 10:00:00 EST" )
        ny_time += gregorian.days(3)
        self.failUnless( ny_time.to_string() == "2003-Dec-23 10:00:00 EST" )

        d = gregorian.date(2003, date_time.Aug, 28)
        sv_pt = posix_time.ptime(date_time.pos_infin)
        sv_lt = local_time.local_date_time(sv_pt, ny_tz)
        utc_pt = posix_time.ptime(d, posix_time.hours(12))
        
        utc_lt = local_time.local_date_time(utc_pt, null_tz)           
        az_lt = local_time.local_date_time(d, posix_time.hours(5), az_tz, False)  
        ny_lt = local_time.local_date_time(d, posix_time.hours(8), ny_tz, True)   
        au_lt = local_time.local_date_time(d, posix_time.hours(22), sydney, False)
        
        self.failUnless( az_lt == utc_lt ) 
        self.failUnless( ny_lt == utc_lt ) 
        self.failUnless( au_lt == utc_lt ) 
        self.failUnless( au_lt <= utc_lt ) 
        self.failUnless( au_lt >= utc_lt ) 
        self.failUnless( az_lt == ny_lt )  
        self.failUnless( az_lt < ny_lt + posix_time.seconds(1) ) 
        self.failUnless( az_lt + posix_time.seconds(1) >  ny_lt ) 
        self.failUnless( az_lt <= ny_lt ) 
        self.failUnless( az_lt >=  ny_lt ) 
        self.failUnless( az_lt + posix_time.seconds(1) !=  ny_lt ) 
        
        au_lt += posix_time.hours(1)
        self.failUnless( au_lt != utc_lt ) 
        self.failUnless( utc_lt <= au_lt )  
        self.failUnless( au_lt >= utc_lt ) 
        self.failUnless( utc_lt < au_lt ) 
        self.failUnless( au_lt > utc_lt )
        au_lt -= posix_time.hours(1)
        self.failUnless( au_lt == utc_lt ) 
        
        self.failUnless( (az_lt + gregorian.days(2)).to_string() == "2003-Aug-30 05:00:00 MST")
        self.failUnless( (az_lt - gregorian.days(2)).to_string() == "2003-Aug-26 05:00:00 MST")
        
        az_lt += gregorian.days(2)
        self.failUnless( az_lt.to_string() == "2003-Aug-30 05:00:00 MST")
        az_lt -= gregorian.days(2)
        self.failUnless( az_lt.to_string() == "2003-Aug-28 05:00:00 MST")
        self.failUnless( (az_lt + posix_time.hours(2)).to_string() == "2003-Aug-28 07:00:00 MST")
        self.failUnless( (az_lt - posix_time.hours(2)).to_string() == "2003-Aug-28 03:00:00 MST")
        
        self.failUnless( sv_lt > au_lt) 
        sv_lt2 = sv_lt + gregorian.days(2)
        self.failUnless( sv_lt2 == sv_lt)

        m = gregorian.months(2)
        y = gregorian.years(2)
        self.failUnless( (az_lt + m).to_string() == "2003-Oct-28 05:00:00 MST")
        az_lt += m
        self.failUnless( az_lt.to_string() == "2003-Oct-28 05:00:00 MST")
        self.failUnless( (az_lt - m).to_string() == "2003-Aug-28 05:00:00 MST")
        az_lt -= m
        self.failUnless( az_lt.to_string() == "2003-Aug-28 05:00:00 MST")
        self.failUnless( (az_lt + y).to_string() == "2005-Aug-28 05:00:00 MST")
        az_lt += y
        self.failUnless( az_lt.to_string() == "2005-Aug-28 05:00:00 MST")
        self.failUnless( (az_lt - y).to_string() == "2003-Aug-28 05:00:00 MST")
        az_lt -= y
        self.failUnless( az_lt.to_string() == "2003-Aug-28 05:00:00 MST")
예제 #5
0
    def test_greg_durations(self):
        m1 = gregorian.months(5)
        m2 = gregorian.months(3)
        m3 = gregorian.months(1)
        self.failUnless( gregorian.months(8) == m1 + m2)
        m1 += m2
        self.failUnless( gregorian.months(8) == m1)
        self.failUnless( gregorian.months(-5) == m2 - m1)
        m2 -= m1;
        self.failUnless( gregorian.months(-5) == m2)
      
        d1 = gregorian.date(2005, date_time.Jan, 1)

        self.failUnless( d1 + gregorian.months(-1) 
                         == gregorian.date(2004, date_time.Dec, 1) )
        d3 = gregorian.date(2005, date_time.Dec, 1);
        self.failUnless( d3 - gregorian.months(-1) 
                         == gregorian.date(2006,date_time.Jan,1))
        m1 = gregorian.months(5)
        m2 = gregorian.months(3)
        m3 = gregorian.months(10)
        self.failUnless( gregorian.months(15) == m1 * 3)
        m1 *= 3
        self.failUnless( gregorian.months(15) == m1)
        self.failUnless( gregorian.months(12) == m2 * 4)
        self.failUnless( gregorian.months(3) == m3 / 3)
        m3 /= 3
        self.failUnless( gregorian.months(3) == m3)

        m = gregorian.months(-5)
        m_pos = gregorian.months(date_time.pos_infin)
        m_neg = gregorian.months(date_time.neg_infin)
        m_nadt = gregorian.months(date_time.not_a_date_time)
        self.failUnless( m + m_pos == m_pos)
        self.failUnless( m + m_neg == m_neg)
        self.failUnless( m_pos + m_neg == m_nadt)
        self.failUnless( m_neg + m_neg == m_neg)
        self.failUnless( m - m_pos == m_neg)
        self.failUnless( m - m_neg == m_pos)
        self.failUnless( m_pos - m_neg == m_pos)
        self.failUnless( m_pos * -1 == m_neg)
        self.failUnless( m_pos * 0 == m_nadt)
        self.failUnless( m_neg / 3 == m_neg)
       
        y1 = gregorian.years(2)
        y2 = gregorian.years(4)
        self.failUnless( gregorian.months(27) == m3 + y1)
        m3 += y1
        self.failUnless( gregorian.months(27) == m3)
        self.failUnless( gregorian.months(-21) == m3 - y2)
        m3 -= y2
        self.failUnless( gregorian.months(-21) == m3)

        d = gregorian.date(2001, date_time.Oct, 31);
        self.failUnless( gregorian.date(2002, date_time.Feb, 28) 
                         == d + gregorian.months(4))
        d += gregorian.months(4)
        self.failUnless( gregorian.date(2002, date_time.Feb, 28) == d);
        d = gregorian.date(2001, date_time.Oct, 31);
        self.failUnless( gregorian.date(2001, date_time.Apr, 30) 
                         == d - gregorian.months(6));
        d -= gregorian.months(6);
        self.failUnless( gregorian.date(2001, date_time.Apr, 30) == d);

        y1 = gregorian.years(2)
        y2 = gregorian.years(4)
        y3 = gregorian.years(1)
        self.failUnless( gregorian.years(3) == y3 + y1)
        y3 += y1
        self.failUnless( gregorian.years(3) == y3)
        self.failUnless( gregorian.years(-1) == y3 - y2)
        y3 -= y2
        self.failUnless( gregorian.years(-1) == y3)
       
        y1 = gregorian.years(5)
        y2 = gregorian.years(3)
        y3 = gregorian.years(10)
        
        self.failUnless( gregorian.years(15) == y1 * 3)
        y1 *= 3
        self.failUnless( gregorian.years(15) == y1)

        self.failUnless( gregorian.years(3) == y3 / 3)
        y3 /= 3
        self.failUnless( gregorian.years(3) == y3)

        m = gregorian.years(15)
        y_pos = gregorian.years(date_time.pos_infin)
        y_neg = gregorian.years(date_time.neg_infin)
        y_nadt = gregorian.years(date_time.not_a_date_time)
        self.failUnless( m + y_pos == y_pos)
        self.failUnless( m + y_neg == y_neg)
        self.failUnless( y_pos + y_neg == y_nadt)
        self.failUnless( y_neg + y_neg == y_neg)
        self.failUnless( m - y_pos == y_neg)
        self.failUnless( m - y_neg == y_pos)
        self.failUnless( y_pos - y_neg == y_pos)
        self.failUnless( y_pos * -1 == y_neg)
        self.failUnless( y_pos * 0 == y_nadt)
        self.failUnless( y_neg / 3 == y_neg)

        m1 = gregorian.months(5)
        m2 = gregorian.months(3)
        self.failUnless( gregorian.months(39) == y2 + m2)
        self.failUnless( gregorian.months(31) == y2 - m1)
   
        d = gregorian.date(2001, date_time.Feb, 28)
        self.failUnless( gregorian.date(2004, date_time.Feb, 29) == d + gregorian.years(3))
        d += gregorian.years(3)
        self.failUnless( gregorian.date(2004, date_time.Feb, 29) == d)
         
        d = gregorian.date(2000, date_time.Feb, 29)
        self.failUnless( gregorian.date(1994, date_time.Feb, 28) == d - gregorian.years(6))
        d -= gregorian.years(6)
        self.failUnless( gregorian.date(1994, date_time.Feb, 28) == d)

        w1 = gregorian.weeks(2)
        w2 = gregorian.weeks(4)
        w3 = gregorian.weeks(1)
        pi = gregorian.weeks(date_time.pos_infin)
        self.failUnless( gregorian.weeks(date_time.pos_infin) == w1 + pi)
        self.failUnless( gregorian.weeks(3) == w3 + w1)
        w3 += w1
        self.failUnless( gregorian.weeks(3) == w3)
        self.failUnless( gregorian.weeks(-1) == w3 - w2)
        w3 -= w2
        self.failUnless( gregorian.weeks(-1) == w3)

        d = gregorian.days(10)
        self.failUnless( gregorian.days(31) == d + gregorian.weeks(3))
        d += gregorian.weeks(3);
        self.failUnless( gregorian.days(31) == d)

        d = gregorian.days(10)
        self.failUnless( gregorian.days(-32) == d - gregorian.weeks(6))
        d -= gregorian.weeks(6)
        self.failUnless( gregorian.days(-32) == d)
        
        d = gregorian.date(2001, date_time.Feb, 28)
        self.failUnless( gregorian.date(2001, date_time.Mar, 21) == d + gregorian.weeks(3))
        d += gregorian.weeks(3)
        self.failUnless( gregorian.date(2001, date_time.Mar, 21) == d)
        
        d = gregorian.date(2001, date_time.Feb, 28);
        self.failUnless( gregorian.date(2001, date_time.Jan, 17) == d - gregorian.weeks(6))
        d -= gregorian.weeks(6)
        self.failUnless( gregorian.date(2001, date_time.Jan, 17) == d)

        d = gregorian.date(2000, date_time.Oct, 31)
        d2 = d + gregorian.months(4) + gregorian.years(2)
        d3 = d + gregorian.years(2) + gregorian.months(4)
        self.failUnless( gregorian.date(2003, date_time.Feb,28) == d2)
        self.failUnless( gregorian.date(2003,date_time.Feb,28) == d3)
        m = gregorian.years(2) + gregorian.months(4) - gregorian.months(4) - gregorian.years(2)
        self.failUnless( m.number_of_months() == 0)