class: RegressionTests::TimeAndDateTest
added:
#test_12_dateQueries
#test_13_timestampQueries
comment/format in: #test_02_ReadingDates
tests for dates before 1900
--- a/RegressionTests__TimeAndDateTest.st Wed Nov 05 22:32:32 2014 +0100
+++ b/RegressionTests__TimeAndDateTest.st Thu Nov 06 16:47:58 2014 +0100
@@ -433,6 +433,62 @@
"
self new test_11_readingISO8601_timezone
"
+!
+
+test_12_dateQueries
+ |d1 d2|
+
+ d1 := Date newDay:1 month:1 year:1940.
+ d2 := Date newDay:1 month:1 year:1941.
+ self assert:(d2 - d1) = 366.
+
+ d1 := Date newDay:1 month:1 year:1840.
+ d2 := Date newDay:1 month:1 year:1841.
+ self assert:(d2 - d1) = 366.
+
+ self assert:(d1 addDays:366) = d2.
+
+ "
+ self new test_12_dateQueries
+ "
+!
+
+test_13_timestampQueries
+ |d1 d2 l u|
+
+ d1 := UtcTimestamp newDay:1 month:1 year:2000.
+ d2 := UtcTimestamp newDay:1 month:1 year:2001.
+ self assert:(d2 - d1) days = 366.
+
+ d1 := UtcTimestamp newDay:2 month:1 year:1940.
+ d2 := UtcTimestamp newDay:2 month:1 year:1941.
+ self assert:d1 asDate year = 1940.
+ self assert:d2 asDate year = 1941.
+ self assert:d1 asDate month = 1.
+ self assert:d2 asDate month = 1.
+ self assert:d1 asDate day = 2.
+ self assert:d2 asDate day = 2.
+
+ self assert:d1 asDate isLeapYear.
+ self assert:d2 asDate isLeapYear not.
+ self assert:(d2 - d1) days = 366.
+
+ d1 := UtcTimestamp newDay:1 month:1 year:1840.
+ d2 := UtcTimestamp newDay:1 month:1 year:1841.
+ self assert:d1 asDate isLeapYear.
+ self assert:d2 asDate isLeapYear not.
+ self assert:(d2 - d1) days = 366.
+
+ self assert:(d1 addDays:366) = d2.
+
+ "/ local time vs. utc time
+ l := Timestamp newDay:1 month:1 year:1940.
+ u := UtcTimestamp newDay:1 month:1 year:1940.
+ self assert:(l asUtcTimestamp - u asUtcTimestamp) asSeconds = Timestamp now utcOffset.
+
+ "
+ self new test_13_timestampQueries
+ "
! !
!TimeAndDateTest class methodsFor:'documentation'!