RegressionTests__TimeAndDateTest.st
changeset 1225 67d011bbcad5
parent 1224 85b0ce90c09b
child 1226 b5123dd5c3da
equal deleted inserted replaced
1224:85b0ce90c09b 1225:67d011bbcad5
   436 !
   436 !
   437 
   437 
   438 test_12_dateQueries
   438 test_12_dateQueries
   439     |d1 d2 d3|
   439     |d1 d2 d3|
   440 
   440 
   441     d1 := Date newDay:1 month:1 year:1940.
   441     d1 := Date newDay:1 month:2 year:1940.    
   442     d2 := Date newDay:1 month:1 year:1941.   
   442     d2 := Date newDay:1 month:2 year:1941.   
   443     self assert:(d2 - d1) = 366.
   443     self assert:(d2 - d1) = 366.
   444 
   444 
   445     d1 := Date newDay:1 month:1 year:1840.
   445     d1 := Date newDay:1 month:2 year:1840.
   446     d2 := Date newDay:1 month:1 year:1841.   
   446     d2 := Date newDay:1 month:2 year:1841.       
   447     self assert:(d2 - d1) = 366.
   447     self assert:(d2 - d1) = 366.
   448 
       
   449     self assert:(d1 addDays:366) = d2.
   448     self assert:(d1 addDays:366) = d2.
       
   449 
       
   450     Date leapYear:1540.    
       
   451     d1 := Date newDay:1 month:2 year:1540.  
       
   452     d2 := Date newDay:1 month:2 year:1541.   
       
   453     self assert:(d2 - d1) = 366.
   450 
   454 
   451     d1 := Date newDay:1 year:1901.
   455     d1 := Date newDay:1 year:1901.
   452     self assert:(d1 day = 1).
   456     self assert:(d1 day = 1).
   453     self assert:(d1 month = 1).
   457     self assert:(d1 month = 1).
   454     self assert:(d1 year = 1901).
   458     self assert:(d1 year = 1901).
   500     self assert:d2 asDate isLeapYear not.
   504     self assert:d2 asDate isLeapYear not.
   501     self assert:(d2 - d1) days = 366.
   505     self assert:(d2 - d1) days = 366.
   502 
   506 
   503     self assert:(d1 addDays:366) = d2.
   507     self assert:(d1 addDays:366) = d2.
   504 
   508 
       
   509     d1 := UtcTimestamp newDay:1 month:1 year:1540.
       
   510     d2 := UtcTimestamp newDay:1 month:1 year:1541.   
       
   511     self assert:d1 asDate isLeapYear.
       
   512     self assert:d2 asDate isLeapYear not.
       
   513     self assert:(d2 - d1) days = 366.
       
   514 
   505     "/ local time vs. utc time
   515     "/ local time vs. utc time
   506     l := Timestamp newDay:1 month:1 year:1940.
   516     l := Timestamp newDay:1 month:1 year:1940.
   507     u := UtcTimestamp newDay:1 month:1 year:1940.
   517     u := UtcTimestamp newDay:1 month:1 year:1940.
   508     self assert:(l asUtcTimestamp - u asUtcTimestamp) asSeconds = Timestamp now utcOffset.
   518     self assert:(l asUtcTimestamp - u asUtcTimestamp) asSeconds = Timestamp now utcOffset.
   509 
   519