#QUALITY by cg
authorClaus Gittinger <cg@exept.de>
Sat, 13 Jul 2019 14:16:52 +0200
changeset 2330 c7cb74c4ed7b
parent 2329 6763cf01c241
child 2331 ebd02b4587a8
#QUALITY by cg class: RegressionTests::TimeAndDateTest added: #test_21_readingDateInVariousFormats category of: #test_01a_ReadingTimes #test_01b_ReadingTimeDurations #test_01c_ReadingTimeStamps #test_01d_ReadingTimeStamps #test_02_ReadingDates #test_06_readingISO8601 #test_07_readingISO8601 #test_07b_readingISO8601UTC #test_08_readingISO8601_date #test_09_readingISO8601_edge #test_10_readingISO8601_time #test_11_readingISO8601_timezone #test_16_readingOtherFormats #test_17_readingBrokenStrings
RegressionTests__TimeAndDateTest.st
--- a/RegressionTests__TimeAndDateTest.st	Fri Jul 12 14:52:10 2019 +0200
+++ b/RegressionTests__TimeAndDateTest.st	Sat Jul 13 14:16:52 2019 +0200
@@ -12,6 +12,410 @@
 
 !TimeAndDateTest methodsFor:'Testing'!
 
+test_03_calenderWeek
+    self assert:(Date newDay:5 month:11 year:2012) weekInYear == 45.
+    self assert:(Date newDay:11 month:11 year:2012) weekInYear == 45.
+
+    self assert:(Date newDay:4 month:11 year:2012) weekInYear == 44.
+    self assert:(Date newDay:12 month:11 year:2012) weekInYear == 46.
+
+    self assert:(Date newDay:29 month:12 year:2014) weekInYear == 1.    "/ YES!!
+    self assert:(Date newDay:30 month:12 year:2014) weekInYear == 1.    "/ YES!!
+    self assert:(Date newDay:31 month:12 year:2014) weekInYear == 1.    "/ YES!!
+    self assert:(Date newDay:1 month:1 year:2015) weekInYear == 1.
+    self assert:(Date newDay:2 month:1 year:2015) weekInYear == 1.
+    self assert:(Date newDay:3 month:1 year:2015) weekInYear == 1.
+    self assert:(Date newDay:4 month:1 year:2015) weekInYear == 1.
+
+    self assert:(Date newDay:5 month:1 year:2015) weekInYear == 2.
+
+    "/ every 4th of january is in the 1st week
+    1902 to:2100 do:[:y |
+	|d|
+	d := Date newDay:4 month:1 year:y.
+	self assert:d weekInYear == 1.
+    ].
+
+    "
+     self new test_03_calenderWeek
+    "
+!
+
+test_04_calenderWeek_fails
+    <test: broken>
+^ self.
+    "/ currently fails for date before 1901
+    1900 to:1905 do:[:y |
+	|d|
+	d := Date newDay:4 month:1 year:y.
+	self assert:d weekInYear == 1.
+    ].
+
+    "
+     self new test_04_calenderWeek_fails
+    "
+!
+
+test_05_weekDayConversion
+    {
+	{ #( 6 53 2004) "2004-W53-6" . (Date newDay:1 month:1 year:2005) }   .
+	{ #( 7 53 2004) "2004-W53-7" . (Date newDay:2 month:1 year:2005) }   .
+	{ #( 6 52 2005) "2005-W52-6" . (Date newDay:31 month:12 year:2005) } .
+	{ #( 1 1  2007) "2007-W01-1" . (Date newDay:1 month:1 year:2007) }   .
+	{ #( 7 52 2007) "2007-W52-7" . (Date newDay:30 month:12 year:2007) } .
+
+	{ #( 1 1  2008) "2008-W01-1" . (Date newDay:31 month:12 year:2007) } .
+	{ #( 2 1  2008) "2008-W01-2" . (Date newDay:1 month:1 year:2008) }   .
+	{ #( 7 52 2008) "2008-W52-7" . (Date newDay:28 month:12 year:2008) } .
+
+	{ #( 1 1  2009) "2009-W01-1" . (Date newDay:29 month:12 year:2008) }     .
+	{ #( 2 1  2009) "2009-W01-2" . (Date newDay:30 month:12 year:2008) }     .
+	{ #( 3 1  2009) "2009-W01-3" . (Date newDay:31 month:12 year:2008) }     .
+	{ #( 4 1  2009) "2009-W01-4" . (Date newDay:1 month:1 year:2009) }       .
+
+	{ #( 4 53 2009) "2009-W53-4" . (Date newDay:31 month:12 year:2009) }     .
+	{ #( 5 53 2009) "2009-W53-5" . (Date newDay:1 month:1 year:2010) }       .
+	{ #( 6 53 2009) "2009-W53-6" . (Date newDay:2 month:1 year:2010) }       .
+	{ #( 7 53 2009) "2009-W53-7" . (Date newDay:3 month:1 year:2010) }       .
+
+	{ #( 1 1  1997) "1997-W01-1" . (Date newDay:30 month:12 year:1996) } .
+    } do:[:eachPair |
+	|dwy d1 d2 dayInWeek weekNr year|
+
+	dwy := eachPair first.
+	dayInWeek := dwy first.
+	weekNr := dwy second.
+	year := dwy third.
+	d1 := Date newDayInWeek:dayInWeek week:weekNr year:year.
+
+	d2 := eachPair second.
+	self assert:(d1 = d2) description:'wrong: ',d1 printString, ' vs. ',d2 printString.
+	self assert:(d1 weekInYear == weekNr).
+	self assert:(d1 dayInWeek == dayInWeek).
+    ]
+
+    "
+     self new test_05_weekDayConversion
+    "
+!
+
+test_12_dateQueries
+    |d1 d2 d3|
+
+    d1 := Date newDay:1 month:2 year:1940.
+    d2 := Date newDay:1 month:2 year:1941.
+    self assert:(d2 - d1) = 366.
+
+    d1 := Date newDay:1 month:2 year:1840.
+    d2 := Date newDay:1 month:2 year:1841.
+    self assert:(d2 - d1) = 366.
+    self assert:(d1 addDays:366) = d2.
+
+    Date leapYear:1540.
+    d1 := Date newDay:1 month:2 year:1540.
+    d2 := Date newDay:1 month:2 year:1541.
+    self assert:(d2 - d1) = 366.
+
+    d1 := Date newDay:1 year:1901.
+    self assert:(d1 day = 1).
+    self assert:(d1 month = 1).
+    self assert:(d1 year = 1901).
+
+    "/ 1900 was NOT a leap year
+    self assert:(Date leapYear:1900) not.
+    "/ 2000 was a leap year
+    self assert:(Date leapYear:2000).
+
+    d2 := d1 subtractDays:365.
+    self assert:(d2 day = 1).
+    self assert:(d2 month = 1).
+    self assert:(d2 year = 1900).
+
+    d3 := d2 subtractDays:365.
+    self assert:(d3 day = 1).
+    self assert:(d3 month = 1).
+    self assert:(d3 year = 1899).
+
+    d1 := Date newDay:1 month:2 year:2540.
+    d2 := Date newDay:1 month:2 year:2541.
+    self assert:(d2 - d1) = 366.
+
+
+    "
+     self new test_12_dateQueries
+    "
+!
+
+test_13_timestampQueries
+    |d1 d2 local utc|
+
+    d1 := UtcTimestamp year:2000 month:1 day:1.
+    d2 := UtcTimestamp year:2001 month:1 day:1.
+    self assert:(d2 - d1) days = 366.
+
+    d1 := UtcTimestamp year:1940 month:1 day:2.
+    d2 := UtcTimestamp year:1941 month:1 day:2.
+    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 year:1840 month:1 day:1.
+    d2 := UtcTimestamp year:1841 month:1 day:1.
+    self assert:d1 asDate isLeapYear.
+    self assert:d2 asDate isLeapYear not.
+    self assert:(d2 - d1) days = 366.
+
+    self assert:(d1 addDays:366) = d2.
+
+    d1 := UtcTimestamp year:1540 month:1 day:1.
+    d2 := UtcTimestamp year:1541 month:1 day:1.
+    self assert:d1 asDate isLeapYear.
+    self assert:d2 asDate isLeapYear not.
+    self assert:(d2 - d1) days = 366.
+
+    d1 := UtcTimestamp year:2038 month:1 day:1.
+    d2 := UtcTimestamp year:2039 month:1 day:1.
+    self assert:d1 asDate isLeapYear not.
+    self assert:d2 asDate isLeapYear not.
+    self assert:(d2 - d1) days = 365.
+
+    d1 := UtcTimestamp year:2540 month:1 day:1.
+    d2 := UtcTimestamp year:2541 month:1 day:1.
+    self assert:d1 asDate isLeapYear.
+    self assert:d2 asDate isLeapYear not.
+    self assert:(d2 - d1) days = 366.
+
+    d1 := UtcTimestamp year:3540 month:1 day:1.
+    d2 := UtcTimestamp year:3541 month:1 day:1.
+    self assert:d1 asDate isLeapYear.
+    self assert:d2 asDate isLeapYear not.
+    self assert:(d2 - d1) days = 366.
+
+    d1 := UtcTimestamp year:1969 month:1 day:1.
+    d2 := UtcTimestamp year:1970 month:1 day:1.
+    self assert:d1 asDate isLeapYear not.
+    self assert:d2 asDate isLeapYear not.
+    self assert:(d2 - d1) days = 365.
+
+    d1 := UtcTimestamp year:1600 month:1 day:1.
+    d2 := UtcTimestamp year:1601 month:1 day:1.
+    self assert:d1 asDate isLeapYear.
+    self assert:d2 asDate isLeapYear not.
+    self assert:(d2 - d1) days = 366.
+
+    "/ local time vs. utc time
+    local := Timestamp year:1940 month:1 day:1.
+    utc := UtcTimestamp year:1940 month:1 day:1.
+    self assert:(local asUtcTimestamp - utc asUtcTimestamp) asSeconds = local utcOffset.
+
+    "/ tz time vs. utc time
+    utc := Timestamp readFrom:'20000102T123000Z'.
+    local := Timestamp readFrom:'20000102T123000+02'.
+    self assert:(utc - local) asSeconds = 7200.
+
+    "/ tz time vs. utc time
+    utc := UtcTimestamp readFrom:'20000102T123000Z'.
+    local := UtcTimestamp readFrom:'20000102T123000-02'.
+    self assert:(utc - local) asSeconds = -7200.
+
+    "
+     self new test_13_timestampQueries
+    "
+
+    "Modified: / 27-07-2018 / 09:59:25 / Stefan Vogel"
+!
+
+test_14_arithmetic
+    |t1 t2 t3 s|
+
+    t1 := UtcTimestamp newDay:1 month:1 year:2000.
+    t2 := t1 addDays:1.
+    self assert:(t2 - t1) days = 1.
+
+    t2 := t1 addHours:1.
+    self assert:(t2 - t1) hours = 1.
+
+    t2 := t1 addSeconds:1.
+    self assert:(t2 - t1) seconds = 1.
+
+    t1 := UtcTimestamp readFrom:'20000102T133045Z'.
+    t2 := t1 addDays:1.
+    self assert:(t2 printString = '2000-01-03 13:30:45Z').
+
+    t1 := Timestamp readFrom:'20000102T133045+01'.
+    t2 := t1 addDays:1.
+    self assert:(t2 printString = '2000-01-03 13:30:45+01').
+
+    t1 := UtcTimestamp readFrom:'20000102T133045Z'.
+    t2 := Timestamp readFrom:'20000102T133045Z'.
+    self assert:(t1 = t2).
+
+    t2 := Timestamp readFrom:'20000102T143045+01'.
+    self assert:(t1 = t2).
+
+    t2 := Timestamp readFrom:'20000102T123045-01'.
+    self assert:(t1 = t2).
+
+    t2 := Timestamp readFrom:'20000102T123045'.     "/ a local one
+    s := t2 storeString.
+    t3 := Timestamp readFrom:s.
+
+    self assert:(t2 = t3).
+
+    t1 := TZTimestamp readFrom:'20000102T133045Z'.
+    self assert:(t1 printString = '2000-01-02 13:30:45+00').
+    t1 := UtcTimestamp readFrom:'20000102T133045Z'.
+    self assert:(t1 printString = '2000-01-02 13:30:45Z').
+
+    "
+     self new test_14_arithmetic
+    "
+!
+
+test_15_misc
+    #( 1700  1800  1900  2100  2200 ) do:[:y |
+	self assert:(Date leapYear:y) not
+    ].
+    #( 1600  2000 2400 ) do:[:y |
+	self assert:(Date leapYear:y)
+    ].
+
+    "
+     self new test_15_misc
+    "
+!
+
+test_18_moreTimestampArithmetic
+    |t1 t2|
+
+    t1 := Timestamp year:2000 month:1 day:1.
+    t2 := t1 addMilliseconds:1.
+    self assert:t1 seconds = 0.
+    self assert:t2 seconds = 0.
+    self assert:t1 exactSeconds = 0.
+    self assert:t2 exactSeconds = 0.001.
+    self assert:t1 milliseconds = 0.
+    self assert:t2 milliseconds = 1.
+    self assert:t1 microseconds = 0.
+    self assert:t2 microseconds = 1000.
+    self assert:t1 nanoseconds = 0.
+    self assert:t2 nanoseconds = 1000000.
+    self assert:t1 picoseconds = 0.
+    self assert:t2 picoseconds = 1000000000.
+
+    self assert:(t2 - t1) milliseconds = 1.
+    self assert:(t2 - t1) microseconds = 1000.
+    self assert:(t2 - t1) nanoseconds = 1000000.
+    self assert:(t2 - t1) picoseconds = 1000000000.
+
+    "
+     self new test_18_moreArithmetic
+    "
+!
+
+test_19_comparing
+    |t1 t2|
+
+    t1 := Time now.
+    t2 := t1 addMilliseconds:1.
+
+    self assert:t2 > t1.
+    self assert:t2 >= t1.
+    self assert:(t2 = t1) not.
+    self assert:(t2 <= t1) not.
+    self assert:(t2 < t1) not.
+
+    t1 := Time now.
+    t2 := t1 subtractMilliseconds:1.
+
+    self assert:t2 < t1.
+    self assert:t2 <= t1.
+    self assert:(t2 = t1) not.
+    self assert:(t2 >= t1) not.
+    self assert:(t2 > t1) not.
+
+    t1 := Time now.
+    t2 := t1 + 1 milliseconds.
+    self assert:t2 = (t1 addMilliseconds:1).
+
+    t2 := t1 - 1 milliseconds.
+    self assert:t2 = (t1 addMilliseconds:-1).
+    self assert:t2 = (t1 subtractMilliseconds:1).
+
+    "
+     self new test_19_comparing
+    "
+!
+
+test_20_comparing
+    |t1 t2|
+
+    t1 := Timestamp now.
+    t2 := t1 addMilliseconds:1.
+
+    self assert:t2 > t1.
+    self assert:t2 >= t1.
+    self assert:(t2 = t1) not.
+    self assert:(t2 <= t1) not.
+    self assert:(t2 < t1) not.
+
+    t1 := Timestamp now.
+    t2 := t1 subtractMilliseconds:1.
+
+    self assert:t2 < t1.
+    self assert:t2 <= t1.
+    self assert:(t2 = t1) not.
+    self assert:(t2 >= t1) not.
+    self assert:(t2 > t1) not.
+
+    t1 := Timestamp now.
+    t2 := t1 + 1 milliseconds.
+    self assert:t2 = (t1 addMilliseconds:1).
+
+    t2 := t1 - 1 milliseconds.
+    self assert:t2 = (t1 addMilliseconds:-1).
+    self assert:t2 = (t1 subtractMilliseconds:1).
+
+    t1 := Timestamp now.
+    t2 := t1 + 1 microseconds.
+
+    self assert:t2 > t1.
+    self assert:t2 >= t1.
+    self assert:(t2 = t1) not.
+    self assert:(t2 <= t1) not.
+    self assert:(t2 < t1) not.
+
+    t1 := Timestamp now.
+    t2 := t1 - 1 microseconds.
+
+    self assert:t2 < t1.
+    self assert:t2 <= t1.
+    self assert:(t2 = t1) not.
+    self assert:(t2 >= t1) not.
+    self assert:(t2 > t1) not.
+
+    t1 := Timestamp now.
+    t2 := t1 + 1 microseconds.
+    self assert:t2 = (t1 addMilliseconds:0.001).
+
+    t2 := t1 - 1 microseconds.
+    self assert:t2 = (t1 addMilliseconds:-0.001).
+    self assert:t2 = (t1 subtractMilliseconds:0.001).
+
+    "
+     self new test_20_comparing
+    "
+! !
+
+!TimeAndDateTest methodsFor:'tests-reading'!
+
 test_01a_ReadingTimes
     self assert:(Time readFrom:'0:00'    ) = (Time hours:0 minutes:0 seconds:0).
     self assert:(Time readFrom:'2:00'    ) = (Time hours:2 minutes:0 seconds:0).
@@ -291,93 +695,6 @@
     "
 !
 
-test_03_calenderWeek
-    self assert:(Date newDay:5 month:11 year:2012) weekInYear == 45.
-    self assert:(Date newDay:11 month:11 year:2012) weekInYear == 45.
-
-    self assert:(Date newDay:4 month:11 year:2012) weekInYear == 44.
-    self assert:(Date newDay:12 month:11 year:2012) weekInYear == 46.
-
-    self assert:(Date newDay:29 month:12 year:2014) weekInYear == 1.    "/ YES!!
-    self assert:(Date newDay:30 month:12 year:2014) weekInYear == 1.    "/ YES!!
-    self assert:(Date newDay:31 month:12 year:2014) weekInYear == 1.    "/ YES!!
-    self assert:(Date newDay:1 month:1 year:2015) weekInYear == 1.
-    self assert:(Date newDay:2 month:1 year:2015) weekInYear == 1.
-    self assert:(Date newDay:3 month:1 year:2015) weekInYear == 1.
-    self assert:(Date newDay:4 month:1 year:2015) weekInYear == 1.
-
-    self assert:(Date newDay:5 month:1 year:2015) weekInYear == 2.
-
-    "/ every 4th of january is in the 1st week
-    1902 to:2100 do:[:y |
-	|d|
-	d := Date newDay:4 month:1 year:y.
-	self assert:d weekInYear == 1.
-    ].
-
-    "
-     self new test_03_calenderWeek
-    "
-!
-
-test_04_calenderWeek_fails
-    <test: broken>
-^ self.
-    "/ currently fails for date before 1901
-    1900 to:1905 do:[:y |
-	|d|
-	d := Date newDay:4 month:1 year:y.
-	self assert:d weekInYear == 1.
-    ].
-
-    "
-     self new test_04_calenderWeek_fails
-    "
-!
-
-test_05_weekDayConversion
-    {
-	{ #( 6 53 2004) "2004-W53-6" . (Date newDay:1 month:1 year:2005) }   .
-	{ #( 7 53 2004) "2004-W53-7" . (Date newDay:2 month:1 year:2005) }   .
-	{ #( 6 52 2005) "2005-W52-6" . (Date newDay:31 month:12 year:2005) } .
-	{ #( 1 1  2007) "2007-W01-1" . (Date newDay:1 month:1 year:2007) }   .
-	{ #( 7 52 2007) "2007-W52-7" . (Date newDay:30 month:12 year:2007) } .
-
-	{ #( 1 1  2008) "2008-W01-1" . (Date newDay:31 month:12 year:2007) } .
-	{ #( 2 1  2008) "2008-W01-2" . (Date newDay:1 month:1 year:2008) }   .
-	{ #( 7 52 2008) "2008-W52-7" . (Date newDay:28 month:12 year:2008) } .
-
-	{ #( 1 1  2009) "2009-W01-1" . (Date newDay:29 month:12 year:2008) }     .
-	{ #( 2 1  2009) "2009-W01-2" . (Date newDay:30 month:12 year:2008) }     .
-	{ #( 3 1  2009) "2009-W01-3" . (Date newDay:31 month:12 year:2008) }     .
-	{ #( 4 1  2009) "2009-W01-4" . (Date newDay:1 month:1 year:2009) }       .
-
-	{ #( 4 53 2009) "2009-W53-4" . (Date newDay:31 month:12 year:2009) }     .
-	{ #( 5 53 2009) "2009-W53-5" . (Date newDay:1 month:1 year:2010) }       .
-	{ #( 6 53 2009) "2009-W53-6" . (Date newDay:2 month:1 year:2010) }       .
-	{ #( 7 53 2009) "2009-W53-7" . (Date newDay:3 month:1 year:2010) }       .
-
-	{ #( 1 1  1997) "1997-W01-1" . (Date newDay:30 month:12 year:1996) } .
-    } do:[:eachPair |
-	|dwy d1 d2 dayInWeek weekNr year|
-
-	dwy := eachPair first.
-	dayInWeek := dwy first.
-	weekNr := dwy second.
-	year := dwy third.
-	d1 := Date newDayInWeek:dayInWeek week:weekNr year:year.
-
-	d2 := eachPair second.
-	self assert:(d1 = d2) description:'wrong: ',d1 printString, ' vs. ',d2 printString.
-	self assert:(d1 weekInYear == weekNr).
-	self assert:(d1 dayInWeek == dayInWeek).
-    ]
-
-    "
-     self new test_05_weekDayConversion
-    "
-!
-
 test_06_readingISO8601
     {
 	{ '2004-W53-6'  . 'sat' . (Date newDay:1 month:1 year:2005) }   .
@@ -688,199 +1005,6 @@
     "
 !
 
-test_12_dateQueries
-    |d1 d2 d3|
-
-    d1 := Date newDay:1 month:2 year:1940.
-    d2 := Date newDay:1 month:2 year:1941.
-    self assert:(d2 - d1) = 366.
-
-    d1 := Date newDay:1 month:2 year:1840.
-    d2 := Date newDay:1 month:2 year:1841.
-    self assert:(d2 - d1) = 366.
-    self assert:(d1 addDays:366) = d2.
-
-    Date leapYear:1540.
-    d1 := Date newDay:1 month:2 year:1540.
-    d2 := Date newDay:1 month:2 year:1541.
-    self assert:(d2 - d1) = 366.
-
-    d1 := Date newDay:1 year:1901.
-    self assert:(d1 day = 1).
-    self assert:(d1 month = 1).
-    self assert:(d1 year = 1901).
-
-    "/ 1900 was NOT a leap year
-    self assert:(Date leapYear:1900) not.
-    "/ 2000 was a leap year
-    self assert:(Date leapYear:2000).
-
-    d2 := d1 subtractDays:365.
-    self assert:(d2 day = 1).
-    self assert:(d2 month = 1).
-    self assert:(d2 year = 1900).
-
-    d3 := d2 subtractDays:365.
-    self assert:(d3 day = 1).
-    self assert:(d3 month = 1).
-    self assert:(d3 year = 1899).
-
-    d1 := Date newDay:1 month:2 year:2540.
-    d2 := Date newDay:1 month:2 year:2541.
-    self assert:(d2 - d1) = 366.
-
-
-    "
-     self new test_12_dateQueries
-    "
-!
-
-test_13_timestampQueries
-    |d1 d2 local utc|
-
-    d1 := UtcTimestamp year:2000 month:1 day:1.
-    d2 := UtcTimestamp year:2001 month:1 day:1.
-    self assert:(d2 - d1) days = 366.
-
-    d1 := UtcTimestamp year:1940 month:1 day:2.
-    d2 := UtcTimestamp year:1941 month:1 day:2.
-    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 year:1840 month:1 day:1.
-    d2 := UtcTimestamp year:1841 month:1 day:1.
-    self assert:d1 asDate isLeapYear.
-    self assert:d2 asDate isLeapYear not.
-    self assert:(d2 - d1) days = 366.
-
-    self assert:(d1 addDays:366) = d2.
-
-    d1 := UtcTimestamp year:1540 month:1 day:1.
-    d2 := UtcTimestamp year:1541 month:1 day:1.
-    self assert:d1 asDate isLeapYear.
-    self assert:d2 asDate isLeapYear not.
-    self assert:(d2 - d1) days = 366.
-
-    d1 := UtcTimestamp year:2038 month:1 day:1.
-    d2 := UtcTimestamp year:2039 month:1 day:1.
-    self assert:d1 asDate isLeapYear not.
-    self assert:d2 asDate isLeapYear not.
-    self assert:(d2 - d1) days = 365.
-
-    d1 := UtcTimestamp year:2540 month:1 day:1.
-    d2 := UtcTimestamp year:2541 month:1 day:1.
-    self assert:d1 asDate isLeapYear.
-    self assert:d2 asDate isLeapYear not.
-    self assert:(d2 - d1) days = 366.
-
-    d1 := UtcTimestamp year:3540 month:1 day:1.
-    d2 := UtcTimestamp year:3541 month:1 day:1.
-    self assert:d1 asDate isLeapYear.
-    self assert:d2 asDate isLeapYear not.
-    self assert:(d2 - d1) days = 366.
-
-    d1 := UtcTimestamp year:1969 month:1 day:1.
-    d2 := UtcTimestamp year:1970 month:1 day:1.
-    self assert:d1 asDate isLeapYear not.
-    self assert:d2 asDate isLeapYear not.
-    self assert:(d2 - d1) days = 365.
-
-    d1 := UtcTimestamp year:1600 month:1 day:1.
-    d2 := UtcTimestamp year:1601 month:1 day:1.
-    self assert:d1 asDate isLeapYear.
-    self assert:d2 asDate isLeapYear not.
-    self assert:(d2 - d1) days = 366.
-
-    "/ local time vs. utc time
-    local := Timestamp year:1940 month:1 day:1.
-    utc := UtcTimestamp year:1940 month:1 day:1.
-    self assert:(local asUtcTimestamp - utc asUtcTimestamp) asSeconds = local utcOffset.
-
-    "/ tz time vs. utc time
-    utc := Timestamp readFrom:'20000102T123000Z'.
-    local := Timestamp readFrom:'20000102T123000+02'.
-    self assert:(utc - local) asSeconds = 7200.
-
-    "/ tz time vs. utc time
-    utc := UtcTimestamp readFrom:'20000102T123000Z'.
-    local := UtcTimestamp readFrom:'20000102T123000-02'.
-    self assert:(utc - local) asSeconds = -7200.
-
-    "
-     self new test_13_timestampQueries
-    "
-
-    "Modified: / 27-07-2018 / 09:59:25 / Stefan Vogel"
-!
-
-test_14_arithmetic
-    |t1 t2 t3 s|
-
-    t1 := UtcTimestamp newDay:1 month:1 year:2000.
-    t2 := t1 addDays:1.
-    self assert:(t2 - t1) days = 1.
-
-    t2 := t1 addHours:1.
-    self assert:(t2 - t1) hours = 1.
-
-    t2 := t1 addSeconds:1.
-    self assert:(t2 - t1) seconds = 1.
-
-    t1 := UtcTimestamp readFrom:'20000102T133045Z'.
-    t2 := t1 addDays:1.
-    self assert:(t2 printString = '2000-01-03 13:30:45Z').
-
-    t1 := Timestamp readFrom:'20000102T133045+01'.
-    t2 := t1 addDays:1.
-    self assert:(t2 printString = '2000-01-03 13:30:45+01').
-
-    t1 := UtcTimestamp readFrom:'20000102T133045Z'.
-    t2 := Timestamp readFrom:'20000102T133045Z'.
-    self assert:(t1 = t2).
-
-    t2 := Timestamp readFrom:'20000102T143045+01'.
-    self assert:(t1 = t2).
-
-    t2 := Timestamp readFrom:'20000102T123045-01'.
-    self assert:(t1 = t2).
-
-    t2 := Timestamp readFrom:'20000102T123045'.     "/ a local one
-    s := t2 storeString.
-    t3 := Timestamp readFrom:s.
-
-    self assert:(t2 = t3).
-
-    t1 := TZTimestamp readFrom:'20000102T133045Z'.
-    self assert:(t1 printString = '2000-01-02 13:30:45+00').
-    t1 := UtcTimestamp readFrom:'20000102T133045Z'.
-    self assert:(t1 printString = '2000-01-02 13:30:45Z').
-
-    "
-     self new test_14_arithmetic
-    "
-!
-
-test_15_misc
-    #( 1700  1800  1900  2100  2200 ) do:[:y |
-	self assert:(Date leapYear:y) not
-    ].
-    #( 1600  2000 2400 ) do:[:y |
-	self assert:(Date leapYear:y)
-    ].
-
-    "
-     self new test_15_misc
-    "
-!
-
 test_16_readingOtherFormats
     | ts |
 
@@ -942,126 +1066,52 @@
     "Created: / 09-11-2017 / 10:00:30 / cg"
 !
 
-test_18_moreTimestampArithmetic
-    |t1 t2|
+test_21_readingDateInVariousFormats
+    {
+        '1.1.1990' . '%d %m %y' . (Date year:1990 month:1 day:1 ) .
+        '1.1.2090' . '%d %m %y' . (Date year:2090 month:1 day:1 ) .
+
+        '1.1.49' . '%d %m %(Y1950)' . (Date year:2049 month:1 day:1 ) .
+        '1.1.50' . '%d %m %(Y1950)' . (Date year:1950 month:1 day:1 ) .
+        '1.1.51' . '%d %m %(Y1950)' . (Date year:1951 month:1 day:1 ) .
+        '1.1.99' . '%d %m %(Y1950)' . (Date year:1999 month:1 day:1 ) .
 
-    t1 := Timestamp year:2000 month:1 day:1.
-    t2 := t1 addMilliseconds:1.
-    self assert:t1 seconds = 0.
-    self assert:t2 seconds = 0.
-    self assert:t1 exactSeconds = 0.
-    self assert:t2 exactSeconds = 0.001.
-    self assert:t1 milliseconds = 0.
-    self assert:t2 milliseconds = 1.
-    self assert:t1 microseconds = 0.
-    self assert:t2 microseconds = 1000.
-    self assert:t1 nanoseconds = 0.
-    self assert:t2 nanoseconds = 1000000.
-    self assert:t1 picoseconds = 0.
-    self assert:t2 picoseconds = 1000000000.
+        '1.1.69' . '%d %m %(Y1970)' . (Date year:2069 month:1 day:1 ) .
+        '1.1.70' . '%d %m %(Y1970)' . (Date year:1970 month:1 day:1 ) .
+        '1.1.71' . '%d %m %(Y1970)' . (Date year:1971 month:1 day:1 ) .
+        '1.1.99' . '%d %m %(Y1970)' . (Date year:1999 month:1 day:1 ) .
 
-    self assert:(t2 - t1) milliseconds = 1.
-    self assert:(t2 - t1) microseconds = 1000.
-    self assert:(t2 - t1) nanoseconds = 1000000.
-    self assert:(t2 - t1) picoseconds = 1000000000.
-
-    "
-     self new test_18_moreArithmetic
-    "
-!
+        '1.1.79' . '%d %m %(Y1980)' . (Date year:2079 month:1 day:1 ) .
+        '1.1.80' . '%d %m %(Y1980)' . (Date year:1980 month:1 day:1 ) .
+        '1.1.81' . '%d %m %(Y1980)' . (Date year:1981 month:1 day:1 ) .
+        '1.1.99' . '%d %m %(Y1980)' . (Date year:1999 month:1 day:1 ) .
 
-test_19_comparing
-    |t1 t2|
-
-    t1 := Time now.
-    t2 := t1 addMilliseconds:1.
-
-    self assert:t2 > t1.
-    self assert:t2 >= t1.
-    self assert:(t2 = t1) not.
-    self assert:(t2 <= t1) not.
-    self assert:(t2 < t1) not.
-
-    t1 := Time now.
-    t2 := t1 subtractMilliseconds:1.
+        '1.1.49' . '%d %m %(Y1900)' . (Date year:1949 month:1 day:1 ) .
+        '1.1.69' . '%d %m %(Y1900)' . (Date year:1969 month:1 day:1 ) .
+        '1.1.79' . '%d %m %(Y1900)' . (Date year:1979 month:1 day:1 ) .
+        '1.1.80' . '%d %m %(Y1900)' . (Date year:1980 month:1 day:1 ) .
+        '1.1.81' . '%d %m %(Y1900)' . (Date year:1981 month:1 day:1 ) .
+        '1.1.99' . '%d %m %(Y1900)' . (Date year:1999 month:1 day:1 ) .
 
-    self assert:t2 < t1.
-    self assert:t2 <= t1.
-    self assert:(t2 = t1) not.
-    self assert:(t2 >= t1) not.
-    self assert:(t2 > t1) not.
+        '1.1.49' . '%d %m %(Y2000)' . (Date year:2049 month:1 day:1 ) .
+        '1.1.69' . '%d %m %(Y2000)' . (Date year:2069 month:1 day:1 ) .
+        '1.1.79' . '%d %m %(Y2000)' . (Date year:2079 month:1 day:1 ) .
+        '1.1.80' . '%d %m %(Y2000)' . (Date year:2080 month:1 day:1 ) .
+        '1.1.81' . '%d %m %(Y2000)' . (Date year:2081 month:1 day:1 ) .
+        '1.1.99' . '%d %m %(Y2000)' . (Date year:2099 month:1 day:1 ) .
+    } inGroupsOf:3 do:[:str :fmt :expected |    
+        | result |
 
-    t1 := Time now.
-    t2 := t1 + 1 milliseconds.
-    self assert:t2 = (t1 addMilliseconds:1).
-
-    t2 := t1 - 1 milliseconds.
-    self assert:t2 = (t1 addMilliseconds:-1).
-    self assert:t2 = (t1 subtractMilliseconds:1).
-
-    "
-     self new test_19_comparing
+        result := Date readFrom:str format:fmt onError:#foo.
+    
+        self assert: result = expected.
+    ].
+    
     "
-!
-
-test_20_comparing
-    |t1 t2|
-
-    t1 := Timestamp now.
-    t2 := t1 addMilliseconds:1.
-
-    self assert:t2 > t1.
-    self assert:t2 >= t1.
-    self assert:(t2 = t1) not.
-    self assert:(t2 <= t1) not.
-    self assert:(t2 < t1) not.
-
-    t1 := Timestamp now.
-    t2 := t1 subtractMilliseconds:1.
-
-    self assert:t2 < t1.
-    self assert:t2 <= t1.
-    self assert:(t2 = t1) not.
-    self assert:(t2 >= t1) not.
-    self assert:(t2 > t1) not.
-
-    t1 := Timestamp now.
-    t2 := t1 + 1 milliseconds.
-    self assert:t2 = (t1 addMilliseconds:1).
+     self new test_21_readingDateInVariousFormats
+    "
 
-    t2 := t1 - 1 milliseconds.
-    self assert:t2 = (t1 addMilliseconds:-1).
-    self assert:t2 = (t1 subtractMilliseconds:1).
-
-    t1 := Timestamp now.
-    t2 := t1 + 1 microseconds.
-
-    self assert:t2 > t1.
-    self assert:t2 >= t1.
-    self assert:(t2 = t1) not.
-    self assert:(t2 <= t1) not.
-    self assert:(t2 < t1) not.
-
-    t1 := Timestamp now.
-    t2 := t1 - 1 microseconds.
-
-    self assert:t2 < t1.
-    self assert:t2 <= t1.
-    self assert:(t2 = t1) not.
-    self assert:(t2 >= t1) not.
-    self assert:(t2 > t1) not.
-
-    t1 := Timestamp now.
-    t2 := t1 + 1 microseconds.
-    self assert:t2 = (t1 addMilliseconds:0.001).
-
-    t2 := t1 - 1 microseconds.
-    self assert:t2 = (t1 addMilliseconds:-0.001).
-    self assert:t2 = (t1 subtractMilliseconds:0.001).
-
-    "
-     self new test_20_comparing
-    "
+    "Created: / 09-11-2017 / 10:00:30 / cg"
 ! !
 
 !TimeAndDateTest class methodsFor:'documentation'!