RegressionTests__TimeAndDateTest.st
author Claus Gittinger <cg@exept.de>
Sat, 13 Jul 2019 14:16:52 +0200
changeset 2330 c7cb74c4ed7b
parent 1992 5cfaf842bed0
child 2391 c4bfc248aace
permissions -rw-r--r--
#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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
     1
"{ Package: 'stx:goodies/regression' }"
346
b2a1db91f556 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
b2a1db91f556 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
"{ NameSpace: RegressionTests }"
b2a1db91f556 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
b2a1db91f556 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
TestCase subclass:#TimeAndDateTest
b2a1db91f556 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
	instanceVariableNames:''
b2a1db91f556 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
	classVariableNames:''
b2a1db91f556 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
	poolDictionaries:''
1077
9cb704988db8 category change
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
     9
	category:'tests-Regression-DateAndTime'
346
b2a1db91f556 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
!
b2a1db91f556 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
b2a1db91f556 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
b2a1db91f556 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
!TimeAndDateTest methodsFor:'Testing'!
b2a1db91f556 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
2330
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    15
test_03_calenderWeek
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    16
    self assert:(Date newDay:5 month:11 year:2012) weekInYear == 45.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    17
    self assert:(Date newDay:11 month:11 year:2012) weekInYear == 45.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    18
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    19
    self assert:(Date newDay:4 month:11 year:2012) weekInYear == 44.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    20
    self assert:(Date newDay:12 month:11 year:2012) weekInYear == 46.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    21
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    22
    self assert:(Date newDay:29 month:12 year:2014) weekInYear == 1.    "/ YES!!
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    23
    self assert:(Date newDay:30 month:12 year:2014) weekInYear == 1.    "/ YES!!
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    24
    self assert:(Date newDay:31 month:12 year:2014) weekInYear == 1.    "/ YES!!
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    25
    self assert:(Date newDay:1 month:1 year:2015) weekInYear == 1.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    26
    self assert:(Date newDay:2 month:1 year:2015) weekInYear == 1.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    27
    self assert:(Date newDay:3 month:1 year:2015) weekInYear == 1.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    28
    self assert:(Date newDay:4 month:1 year:2015) weekInYear == 1.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    29
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    30
    self assert:(Date newDay:5 month:1 year:2015) weekInYear == 2.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    31
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    32
    "/ every 4th of january is in the 1st week
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    33
    1902 to:2100 do:[:y |
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    34
	|d|
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    35
	d := Date newDay:4 month:1 year:y.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    36
	self assert:d weekInYear == 1.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    37
    ].
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    38
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    39
    "
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    40
     self new test_03_calenderWeek
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    41
    "
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    42
!
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    43
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    44
test_04_calenderWeek_fails
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    45
    <test: broken>
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    46
^ self.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    47
    "/ currently fails for date before 1901
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    48
    1900 to:1905 do:[:y |
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    49
	|d|
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    50
	d := Date newDay:4 month:1 year:y.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    51
	self assert:d weekInYear == 1.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    52
    ].
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    53
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    54
    "
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    55
     self new test_04_calenderWeek_fails
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    56
    "
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    57
!
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    58
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    59
test_05_weekDayConversion
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    60
    {
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    61
	{ #( 6 53 2004) "2004-W53-6" . (Date newDay:1 month:1 year:2005) }   .
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    62
	{ #( 7 53 2004) "2004-W53-7" . (Date newDay:2 month:1 year:2005) }   .
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    63
	{ #( 6 52 2005) "2005-W52-6" . (Date newDay:31 month:12 year:2005) } .
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    64
	{ #( 1 1  2007) "2007-W01-1" . (Date newDay:1 month:1 year:2007) }   .
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    65
	{ #( 7 52 2007) "2007-W52-7" . (Date newDay:30 month:12 year:2007) } .
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    66
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    67
	{ #( 1 1  2008) "2008-W01-1" . (Date newDay:31 month:12 year:2007) } .
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    68
	{ #( 2 1  2008) "2008-W01-2" . (Date newDay:1 month:1 year:2008) }   .
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    69
	{ #( 7 52 2008) "2008-W52-7" . (Date newDay:28 month:12 year:2008) } .
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    70
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    71
	{ #( 1 1  2009) "2009-W01-1" . (Date newDay:29 month:12 year:2008) }     .
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    72
	{ #( 2 1  2009) "2009-W01-2" . (Date newDay:30 month:12 year:2008) }     .
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    73
	{ #( 3 1  2009) "2009-W01-3" . (Date newDay:31 month:12 year:2008) }     .
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    74
	{ #( 4 1  2009) "2009-W01-4" . (Date newDay:1 month:1 year:2009) }       .
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    75
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    76
	{ #( 4 53 2009) "2009-W53-4" . (Date newDay:31 month:12 year:2009) }     .
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    77
	{ #( 5 53 2009) "2009-W53-5" . (Date newDay:1 month:1 year:2010) }       .
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    78
	{ #( 6 53 2009) "2009-W53-6" . (Date newDay:2 month:1 year:2010) }       .
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    79
	{ #( 7 53 2009) "2009-W53-7" . (Date newDay:3 month:1 year:2010) }       .
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    80
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    81
	{ #( 1 1  1997) "1997-W01-1" . (Date newDay:30 month:12 year:1996) } .
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    82
    } do:[:eachPair |
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    83
	|dwy d1 d2 dayInWeek weekNr year|
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    84
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    85
	dwy := eachPair first.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    86
	dayInWeek := dwy first.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    87
	weekNr := dwy second.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    88
	year := dwy third.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    89
	d1 := Date newDayInWeek:dayInWeek week:weekNr year:year.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    90
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    91
	d2 := eachPair second.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    92
	self assert:(d1 = d2) description:'wrong: ',d1 printString, ' vs. ',d2 printString.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    93
	self assert:(d1 weekInYear == weekNr).
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    94
	self assert:(d1 dayInWeek == dayInWeek).
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    95
    ]
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    96
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    97
    "
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    98
     self new test_05_weekDayConversion
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
    99
    "
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   100
!
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   101
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   102
test_12_dateQueries
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   103
    |d1 d2 d3|
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   104
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   105
    d1 := Date newDay:1 month:2 year:1940.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   106
    d2 := Date newDay:1 month:2 year:1941.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   107
    self assert:(d2 - d1) = 366.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   108
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   109
    d1 := Date newDay:1 month:2 year:1840.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   110
    d2 := Date newDay:1 month:2 year:1841.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   111
    self assert:(d2 - d1) = 366.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   112
    self assert:(d1 addDays:366) = d2.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   113
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   114
    Date leapYear:1540.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   115
    d1 := Date newDay:1 month:2 year:1540.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   116
    d2 := Date newDay:1 month:2 year:1541.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   117
    self assert:(d2 - d1) = 366.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   118
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   119
    d1 := Date newDay:1 year:1901.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   120
    self assert:(d1 day = 1).
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   121
    self assert:(d1 month = 1).
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   122
    self assert:(d1 year = 1901).
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   123
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   124
    "/ 1900 was NOT a leap year
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   125
    self assert:(Date leapYear:1900) not.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   126
    "/ 2000 was a leap year
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   127
    self assert:(Date leapYear:2000).
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   128
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   129
    d2 := d1 subtractDays:365.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   130
    self assert:(d2 day = 1).
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   131
    self assert:(d2 month = 1).
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   132
    self assert:(d2 year = 1900).
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   133
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   134
    d3 := d2 subtractDays:365.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   135
    self assert:(d3 day = 1).
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   136
    self assert:(d3 month = 1).
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   137
    self assert:(d3 year = 1899).
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   138
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   139
    d1 := Date newDay:1 month:2 year:2540.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   140
    d2 := Date newDay:1 month:2 year:2541.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   141
    self assert:(d2 - d1) = 366.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   142
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   143
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   144
    "
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   145
     self new test_12_dateQueries
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   146
    "
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   147
!
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   148
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   149
test_13_timestampQueries
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   150
    |d1 d2 local utc|
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   151
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   152
    d1 := UtcTimestamp year:2000 month:1 day:1.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   153
    d2 := UtcTimestamp year:2001 month:1 day:1.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   154
    self assert:(d2 - d1) days = 366.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   155
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   156
    d1 := UtcTimestamp year:1940 month:1 day:2.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   157
    d2 := UtcTimestamp year:1941 month:1 day:2.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   158
    self assert:d1 asDate year = 1940.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   159
    self assert:d2 asDate year = 1941.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   160
    self assert:d1 asDate month = 1.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   161
    self assert:d2 asDate month = 1.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   162
    self assert:d1 asDate day = 2.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   163
    self assert:d2 asDate day = 2.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   164
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   165
    self assert:d1 asDate isLeapYear.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   166
    self assert:d2 asDate isLeapYear not.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   167
    self assert:(d2 - d1) days = 366.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   168
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   169
    d1 := UtcTimestamp year:1840 month:1 day:1.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   170
    d2 := UtcTimestamp year:1841 month:1 day:1.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   171
    self assert:d1 asDate isLeapYear.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   172
    self assert:d2 asDate isLeapYear not.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   173
    self assert:(d2 - d1) days = 366.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   174
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   175
    self assert:(d1 addDays:366) = d2.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   176
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   177
    d1 := UtcTimestamp year:1540 month:1 day:1.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   178
    d2 := UtcTimestamp year:1541 month:1 day:1.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   179
    self assert:d1 asDate isLeapYear.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   180
    self assert:d2 asDate isLeapYear not.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   181
    self assert:(d2 - d1) days = 366.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   182
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   183
    d1 := UtcTimestamp year:2038 month:1 day:1.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   184
    d2 := UtcTimestamp year:2039 month:1 day:1.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   185
    self assert:d1 asDate isLeapYear not.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   186
    self assert:d2 asDate isLeapYear not.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   187
    self assert:(d2 - d1) days = 365.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   188
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   189
    d1 := UtcTimestamp year:2540 month:1 day:1.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   190
    d2 := UtcTimestamp year:2541 month:1 day:1.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   191
    self assert:d1 asDate isLeapYear.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   192
    self assert:d2 asDate isLeapYear not.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   193
    self assert:(d2 - d1) days = 366.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   194
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   195
    d1 := UtcTimestamp year:3540 month:1 day:1.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   196
    d2 := UtcTimestamp year:3541 month:1 day:1.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   197
    self assert:d1 asDate isLeapYear.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   198
    self assert:d2 asDate isLeapYear not.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   199
    self assert:(d2 - d1) days = 366.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   200
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   201
    d1 := UtcTimestamp year:1969 month:1 day:1.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   202
    d2 := UtcTimestamp year:1970 month:1 day:1.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   203
    self assert:d1 asDate isLeapYear not.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   204
    self assert:d2 asDate isLeapYear not.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   205
    self assert:(d2 - d1) days = 365.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   206
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   207
    d1 := UtcTimestamp year:1600 month:1 day:1.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   208
    d2 := UtcTimestamp year:1601 month:1 day:1.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   209
    self assert:d1 asDate isLeapYear.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   210
    self assert:d2 asDate isLeapYear not.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   211
    self assert:(d2 - d1) days = 366.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   212
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   213
    "/ local time vs. utc time
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   214
    local := Timestamp year:1940 month:1 day:1.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   215
    utc := UtcTimestamp year:1940 month:1 day:1.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   216
    self assert:(local asUtcTimestamp - utc asUtcTimestamp) asSeconds = local utcOffset.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   217
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   218
    "/ tz time vs. utc time
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   219
    utc := Timestamp readFrom:'20000102T123000Z'.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   220
    local := Timestamp readFrom:'20000102T123000+02'.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   221
    self assert:(utc - local) asSeconds = 7200.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   222
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   223
    "/ tz time vs. utc time
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   224
    utc := UtcTimestamp readFrom:'20000102T123000Z'.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   225
    local := UtcTimestamp readFrom:'20000102T123000-02'.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   226
    self assert:(utc - local) asSeconds = -7200.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   227
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   228
    "
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   229
     self new test_13_timestampQueries
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   230
    "
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   231
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   232
    "Modified: / 27-07-2018 / 09:59:25 / Stefan Vogel"
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   233
!
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   234
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   235
test_14_arithmetic
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   236
    |t1 t2 t3 s|
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   237
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   238
    t1 := UtcTimestamp newDay:1 month:1 year:2000.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   239
    t2 := t1 addDays:1.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   240
    self assert:(t2 - t1) days = 1.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   241
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   242
    t2 := t1 addHours:1.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   243
    self assert:(t2 - t1) hours = 1.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   244
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   245
    t2 := t1 addSeconds:1.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   246
    self assert:(t2 - t1) seconds = 1.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   247
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   248
    t1 := UtcTimestamp readFrom:'20000102T133045Z'.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   249
    t2 := t1 addDays:1.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   250
    self assert:(t2 printString = '2000-01-03 13:30:45Z').
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   251
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   252
    t1 := Timestamp readFrom:'20000102T133045+01'.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   253
    t2 := t1 addDays:1.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   254
    self assert:(t2 printString = '2000-01-03 13:30:45+01').
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   255
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   256
    t1 := UtcTimestamp readFrom:'20000102T133045Z'.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   257
    t2 := Timestamp readFrom:'20000102T133045Z'.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   258
    self assert:(t1 = t2).
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   259
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   260
    t2 := Timestamp readFrom:'20000102T143045+01'.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   261
    self assert:(t1 = t2).
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   262
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   263
    t2 := Timestamp readFrom:'20000102T123045-01'.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   264
    self assert:(t1 = t2).
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   265
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   266
    t2 := Timestamp readFrom:'20000102T123045'.     "/ a local one
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   267
    s := t2 storeString.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   268
    t3 := Timestamp readFrom:s.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   269
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   270
    self assert:(t2 = t3).
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   271
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   272
    t1 := TZTimestamp readFrom:'20000102T133045Z'.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   273
    self assert:(t1 printString = '2000-01-02 13:30:45+00').
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   274
    t1 := UtcTimestamp readFrom:'20000102T133045Z'.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   275
    self assert:(t1 printString = '2000-01-02 13:30:45Z').
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   276
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   277
    "
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   278
     self new test_14_arithmetic
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   279
    "
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   280
!
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   281
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   282
test_15_misc
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   283
    #( 1700  1800  1900  2100  2200 ) do:[:y |
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   284
	self assert:(Date leapYear:y) not
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   285
    ].
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   286
    #( 1600  2000 2400 ) do:[:y |
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   287
	self assert:(Date leapYear:y)
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   288
    ].
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   289
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   290
    "
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   291
     self new test_15_misc
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   292
    "
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   293
!
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   294
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   295
test_18_moreTimestampArithmetic
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   296
    |t1 t2|
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   297
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   298
    t1 := Timestamp year:2000 month:1 day:1.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   299
    t2 := t1 addMilliseconds:1.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   300
    self assert:t1 seconds = 0.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   301
    self assert:t2 seconds = 0.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   302
    self assert:t1 exactSeconds = 0.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   303
    self assert:t2 exactSeconds = 0.001.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   304
    self assert:t1 milliseconds = 0.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   305
    self assert:t2 milliseconds = 1.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   306
    self assert:t1 microseconds = 0.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   307
    self assert:t2 microseconds = 1000.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   308
    self assert:t1 nanoseconds = 0.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   309
    self assert:t2 nanoseconds = 1000000.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   310
    self assert:t1 picoseconds = 0.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   311
    self assert:t2 picoseconds = 1000000000.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   312
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   313
    self assert:(t2 - t1) milliseconds = 1.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   314
    self assert:(t2 - t1) microseconds = 1000.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   315
    self assert:(t2 - t1) nanoseconds = 1000000.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   316
    self assert:(t2 - t1) picoseconds = 1000000000.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   317
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   318
    "
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   319
     self new test_18_moreArithmetic
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   320
    "
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   321
!
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   322
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   323
test_19_comparing
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   324
    |t1 t2|
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   325
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   326
    t1 := Time now.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   327
    t2 := t1 addMilliseconds:1.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   328
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   329
    self assert:t2 > t1.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   330
    self assert:t2 >= t1.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   331
    self assert:(t2 = t1) not.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   332
    self assert:(t2 <= t1) not.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   333
    self assert:(t2 < t1) not.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   334
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   335
    t1 := Time now.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   336
    t2 := t1 subtractMilliseconds:1.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   337
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   338
    self assert:t2 < t1.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   339
    self assert:t2 <= t1.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   340
    self assert:(t2 = t1) not.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   341
    self assert:(t2 >= t1) not.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   342
    self assert:(t2 > t1) not.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   343
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   344
    t1 := Time now.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   345
    t2 := t1 + 1 milliseconds.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   346
    self assert:t2 = (t1 addMilliseconds:1).
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   347
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   348
    t2 := t1 - 1 milliseconds.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   349
    self assert:t2 = (t1 addMilliseconds:-1).
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   350
    self assert:t2 = (t1 subtractMilliseconds:1).
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   351
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   352
    "
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   353
     self new test_19_comparing
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   354
    "
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   355
!
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   356
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   357
test_20_comparing
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   358
    |t1 t2|
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   359
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   360
    t1 := Timestamp now.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   361
    t2 := t1 addMilliseconds:1.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   362
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   363
    self assert:t2 > t1.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   364
    self assert:t2 >= t1.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   365
    self assert:(t2 = t1) not.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   366
    self assert:(t2 <= t1) not.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   367
    self assert:(t2 < t1) not.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   368
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   369
    t1 := Timestamp now.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   370
    t2 := t1 subtractMilliseconds:1.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   371
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   372
    self assert:t2 < t1.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   373
    self assert:t2 <= t1.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   374
    self assert:(t2 = t1) not.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   375
    self assert:(t2 >= t1) not.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   376
    self assert:(t2 > t1) not.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   377
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   378
    t1 := Timestamp now.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   379
    t2 := t1 + 1 milliseconds.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   380
    self assert:t2 = (t1 addMilliseconds:1).
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   381
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   382
    t2 := t1 - 1 milliseconds.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   383
    self assert:t2 = (t1 addMilliseconds:-1).
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   384
    self assert:t2 = (t1 subtractMilliseconds:1).
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   385
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   386
    t1 := Timestamp now.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   387
    t2 := t1 + 1 microseconds.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   388
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   389
    self assert:t2 > t1.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   390
    self assert:t2 >= t1.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   391
    self assert:(t2 = t1) not.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   392
    self assert:(t2 <= t1) not.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   393
    self assert:(t2 < t1) not.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   394
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   395
    t1 := Timestamp now.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   396
    t2 := t1 - 1 microseconds.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   397
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   398
    self assert:t2 < t1.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   399
    self assert:t2 <= t1.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   400
    self assert:(t2 = t1) not.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   401
    self assert:(t2 >= t1) not.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   402
    self assert:(t2 > t1) not.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   403
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   404
    t1 := Timestamp now.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   405
    t2 := t1 + 1 microseconds.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   406
    self assert:t2 = (t1 addMilliseconds:0.001).
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   407
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   408
    t2 := t1 - 1 microseconds.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   409
    self assert:t2 = (t1 addMilliseconds:-0.001).
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   410
    self assert:t2 = (t1 subtractMilliseconds:0.001).
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   411
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   412
    "
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   413
     self new test_20_comparing
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   414
    "
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   415
! !
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   416
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   417
!TimeAndDateTest methodsFor:'tests-reading'!
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
   418
1886
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   419
test_01a_ReadingTimes
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   420
    self assert:(Time readFrom:'0:00'    ) = (Time hours:0 minutes:0 seconds:0).
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   421
    self assert:(Time readFrom:'2:00'    ) = (Time hours:2 minutes:0 seconds:0).
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   422
    self assert:(Time readFrom:'12:00'   ) = (Time hours:12 minutes:0 seconds:0).
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   423
    self assert:(Time readFrom:'14:00'   ) = (Time hours:14 minutes:0 seconds:0).
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   424
    self assert:(Time readFrom:'23:00'   ) = (Time hours:23 minutes:0 seconds:0).
346
b2a1db91f556 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   425
1886
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   426
    self assert:(Time readFrom:'18:22:00') = (Time hours:18 minutes:22 seconds:0).
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   427
    self assert:(Time readFrom:'14:00:11') = (Time hours:14 minutes:0 seconds:11).
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   428
    self assert:(Time readFrom:'7:00:11' ) = (Time hours:7 minutes:0 seconds:11).
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   429
    self assert:(Time readFrom:'0:00:00' ) = (Time hours:0 minutes:0 seconds:0).
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   430
    self assert:(Time readFrom:'12:00:00') = (Time hours:12 minutes:0 seconds:0).
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   431
    self assert:(Time readFrom:'0:00:00' ) = (Time hours:0 minutes:0 seconds:0).
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   432
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   433
    self assert:(Time readFrom:'14'      ) = (Time hours:14 minutes:0 seconds:0).
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   434
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   435
    self assert:(Time readFrom:'2 am'    ) = (Time hours:2 minutes:0 seconds:0).
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   436
    self assert:(Time readFrom:'2 pm'    ) = (Time hours:14 minutes:0 seconds:0).
346
b2a1db91f556 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   437
1886
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   438
    self assert:(Time readFrom:'2:30 am' ) = (Time hours:2 minutes:30 seconds:0).
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   439
    self assert:(Time readFrom:'2:30 pm' ) = (Time hours:14 minutes:30 seconds:0).
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   440
    self assert:(Time readFrom:'12:05 pm') = (Time hours:12 minutes:5 seconds:0).
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   441
    self assert:(Time readFrom:'12:06 am') = (Time hours:0 minutes:6 seconds:0).
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   442
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   443
    self assert:(Time readFrom:'6:22:00 pm' ) = (Time hours:18 minutes:22 seconds:0).
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   444
    self assert:(Time readFrom:'2:00:11 pm' ) = (Time hours:14 minutes:0 seconds:11).
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   445
    self assert:(Time readFrom:'7:00:11 am' ) = (Time hours:7 minutes:0 seconds:11).
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   446
    self assert:(Time readFrom:'12:00:00 am') = (Time hours:0 minutes:0 seconds:0).
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   447
    self assert:(Time readFrom:'0:00:00 am' ) = (Time hours:0 minutes:0 seconds:0).
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   448
    self assert:(Time readFrom:'12:00:00 pm') = (Time hours:12 minutes:0 seconds:0).
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   449
    self assert:(Time readFrom:'0:00:00 pm' onError:'invalid') = 'invalid'.
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   450
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   451
    self assert:(Time readFrom:'24:00'   ) = (Time hours:0 minutes:0 seconds:0).
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   452
    self assert:(Time readFrom:'24:00:00') = (Time hours:0 minutes:0 seconds:0).
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   453
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   454
    self should:[Time readFrom:'24:00:00 am' ] raise:TimeConversionError.
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   455
    self should:[Time readFrom:'24:00:00 pm' ] raise:TimeConversionError.
346
b2a1db91f556 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   456
b2a1db91f556 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   457
    "
1886
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   458
     self new test_01a_ReadingTimes
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   459
    "
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   460
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   461
    "Created: / 09-11-2017 / 10:17:37 / cg"
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   462
!
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   463
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   464
test_01b_ReadingTimeDurations
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   465
    self assert:(TimeDuration readFrom:'0:00'    ) = (TimeDuration hours:0 minutes:0 seconds:0).
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   466
    self assert:(TimeDuration readFrom:'2:00'    ) = (TimeDuration hours:2 minutes:0 seconds:0).
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   467
    self assert:(TimeDuration readFrom:'12:00'   ) = (TimeDuration hours:12 minutes:0 seconds:0).
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   468
    self assert:(TimeDuration readFrom:'14:00'   ) = (TimeDuration hours:14 minutes:0 seconds:0).
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   469
    self assert:(TimeDuration readFrom:'23:00'   ) = (TimeDuration hours:23 minutes:0 seconds:0).
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   470
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   471
    self assert:(TimeDuration readFrom:'18:22:00') = (TimeDuration hours:18 minutes:22 seconds:0).
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   472
    self assert:(TimeDuration readFrom:'14:00:11') = (TimeDuration hours:14 minutes:0 seconds:11).
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   473
    self assert:(TimeDuration readFrom:'7:00:11' ) = (TimeDuration hours:7 minutes:0 seconds:11).
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   474
    self assert:(TimeDuration readFrom:'0:00:00' ) = (TimeDuration hours:0 minutes:0 seconds:0).
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   475
    self assert:(TimeDuration readFrom:'12:00:00') = (TimeDuration hours:12 minutes:0 seconds:0).
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   476
    self assert:(TimeDuration readFrom:'0:00:00' ) = (TimeDuration hours:0 minutes:0 seconds:0).
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   477
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   478
    self assert:(TimeDuration readFrom:'14'      ) = (TimeDuration hours:0 minutes:0 seconds:14).
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   479
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   480
    "
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   481
     self new test_01b_ReadingTimeDurations
346
b2a1db91f556 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   482
    "
1652
df3c6ccdb0e7 #REFACTORING by mawalch
mawalch
parents: 1447
diff changeset
   483
1886
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   484
    "Created: / 09-11-2017 / 10:16:58 / cg"
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   485
!
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   486
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   487
test_01c_ReadingTimeStamps
1924
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   488
    |t|
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   489
1886
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   490
    self assert:(Timestamp readFrom:'2017-11-09 10:18:03.236') = (Timestamp year:2017 month:11 day:9 hour:10 minute:18 second:3 millisecond:236).
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   491
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   492
    "/ standard format
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   493
    self assert:(Timestamp readFrom:'2017-11-09') = (Timestamp year:2017 month:11 day:9 hour:0 minute:0 second:0).
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   494
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   495
    "/ US format
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   496
    self assert:(Timestamp readFrom:'12/09/2017') = (Timestamp year:2017 month:12 day:9 hour:0 minute:0 second:0).
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   497
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   498
    "/ european format
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   499
    self assert:(Timestamp readFrom:'9.11.2017') = (Timestamp year:2017 month:11 day:9 hour:0 minute:0 second:0).
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   500
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   501
    "/ explicit format
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   502
    self assert:(Timestamp readFrom:'9-nov-2017') = (Timestamp year:2017 month:11 day:9 hour:0 minute:0 second:0).
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   503
    "/ explicit format
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   504
    self assert:(Timestamp readFrom:'9. nov 2017') = (Timestamp year:2017 month:11 day:9 hour:0 minute:0 second:0).
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   505
    "/ explicit format
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   506
    self assert:(Timestamp readFrom:'9 nov 2017') = (Timestamp year:2017 month:11 day:9 hour:0 minute:0 second:0).
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   507
1924
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   508
    "/ milliseconds
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   509
    t := Timestamp readFrom:'2017-11-09 10:18:03.123'.
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   510
    self assert:(t milliseconds = 123).
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   511
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   512
    "/ microseconds
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   513
    t := Timestamp readFrom:'2017-11-09 10:18:03.123456'.
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   514
    self assert:(t microseconds = 123456).
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   515
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   516
    "/ nanoseconds
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   517
    t := Timestamp readFrom:'2017-11-09 10:18:03.123456789'.
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   518
    self assert:(t nanoseconds = 123456789).
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   519
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   520
    "/ picoseconds
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   521
    t := Timestamp readFrom:'2017-11-09 10:18:03.123456789012'.
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   522
    self assert:(t picoseconds = 123456789012).
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   523
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   524
    self assert:(t := Timestamp readFrom:'20-2-1995 13:11:06' format:'%day-%month-%year %h:%m:%s' language:nil onError:[self error]
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   525
                ) = (Timestamp year:1995 month:2 day:20 hour:13 minute:11 second:6 millisecond:0). 
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   526
    self assert:(t := Timestamp readFrom:'20021995131106' format:'%2d%2month%4y%2h%2m%2s' language:nil onError:[self error]
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   527
                ) = (Timestamp year:1995 month:2 day:20 hour:13 minute:11 second:6  millisecond:0). 
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   528
    self assert:(t := Timestamp readFrom:'200295131106' format:'%2d%2month%2y%2h%2m%2s' language:nil onError:[self error]
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   529
                ) = (Timestamp year:95 month:2 day:20 hour:13 minute:11 second:6  millisecond:0). 
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   530
    self assert:(t := Timestamp readFrom:'200260131106' format:'%2d%2month%2(y1900)%2h%2m%2s' language:nil onError:[self error]
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   531
                ) = (Timestamp year:1960 month:2 day:20 hour:13 minute:11 second:6 millisecond:0). 
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   532
    self assert:(t := Timestamp readFrom:'200260131106' format:'%2d%2month%2(y2000)%2h%2m%2s' language:nil onError:[self error]
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   533
                ) = (Timestamp year:2060 month:2 day:20 hour:13 minute:11 second:6 millisecond:0). 
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   534
    self assert:(t := Timestamp readFrom:'200260131106' format:'%2d%2month%2(y1950)%2h%2m%2s' language:nil onError:[self error]
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   535
                ) = (Timestamp year:1960 month:2 day:20 hour:13 minute:11 second:6 millisecond:0). 
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   536
    self assert:(t := Timestamp readFrom:'200260131106' format:'%2d%2month%2(y1980)%2h%2m%2s' language:nil onError:[self error]
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   537
                ) = (Timestamp year:2060 month:2 day:20 hour:13 minute:11 second:6 millisecond:0). 
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   538
    self assert:(t := Timestamp readFrom:'March 7 2009 2:30pm ' format:'%monthName %day %year %u:%m%a' language:#en onError:[self error]
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   539
                ) = (Timestamp year:2009 month:3 day:7 hour:14 minute:30 second:0 millisecond:0). "/ EST is 5hrs behind
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   540
    self assert:(t := Timestamp readFrom:'March 7 2009 2:30am ' format:'%monthName %day %year %u:%m%a' language:#en onError:[self error]
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   541
                ) = (Timestamp year:2009 month:3 day:7 hour:2 minute:30 second:0 millisecond:0). "/ EST is 5hrs behind
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   542
1927
ac82d7231d95 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1924
diff changeset
   543
    "/ Timestamp readIso8601FormatFrom:'20090307T183000-05'
ac82d7231d95 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1924
diff changeset
   544
    "/ Timestamp readIso8601FormatFrom:'20090307T233000Z'
ac82d7231d95 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1924
diff changeset
   545
    self assert:(t := Timestamp readFrom:'March 7 2009 6:30pm EST' format:'%monthName %day %year %u:%m%a %tz' language:#en onError:[self error]
ac82d7231d95 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1924
diff changeset
   546
                ) = (UtcTimestamp year:2009 month:3 day:7 hour:23 minute:30 second:0 millisecond:0). "/ EST is 5hrs behind
1924
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   547
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   548
    self assert:(t := Timestamp readFrom:'March 7 2009 7:30pm UTC' format:'%monthName %day %year %u:%m%a %tz' language:#en onError:[self error]
1927
ac82d7231d95 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1924
diff changeset
   549
                ) = (UtcTimestamp year:2009 month:3 day:7 hour:19 minute:30 second:0 millisecond:0). 
1924
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   550
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   551
    self assert:(t := Timestamp readFrom:'2015103' format:'%4y%3dayOfYear' onError:[self error]
1927
ac82d7231d95 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1924
diff changeset
   552
                ) = (Timestamp year:2015 month:4 day:13 hour:0 minute:0 second:0 millisecond:0). 
ac82d7231d95 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1924
diff changeset
   553
    self assert:t asDate dayOfYear == 103.
1924
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   554
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   555
    self assert:(t := Timestamp readFrom:'20-2-1995 13:11:06.999' format:'%day-%month-%year %h:%m:%s.%i' language:nil onError:[self error]
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   556
                ) = (Timestamp year:1995 month:2 day:20 hour:13 minute:11 second:6 millisecond:999). 
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   557
    self assert:(t := Timestamp readFrom:'20-2-1995 13:11:06.100' format:'%day-%month-%year %h:%m:%s.%i' language:nil onError:[self error]
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   558
                ) = (Timestamp year:1995 month:2 day:20 hour:13 minute:11 second:6 millisecond:100). 
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   559
    self assert:(t := Timestamp readFrom:'20-2-1995 13:11:06.010' format:'%day-%month-%year %h:%m:%s.%i' language:nil onError:[self error]
1927
ac82d7231d95 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1924
diff changeset
   560
                ) = (Timestamp year:1995 month:2 day:20 hour:13 minute:11 second:6 millisecond:10). 
1924
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   561
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   562
    self assert:(t := Timestamp readFrom:'20-2-1995 13:11:06.1' format:'%day-%month-%year %h:%m:%s.%f' language:nil onError:[self error]
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   563
                ) = (Timestamp year:1995 month:2 day:20 hour:13 minute:11 second:6 millisecond:100). 
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   564
    self assert:(t := Timestamp readFrom:'20-2-1995 13:11:06.01' format:'%day-%month-%year %h:%m:%s.%f' language:nil onError:[self error]
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   565
                ) = (Timestamp year:1995 month:2 day:20 hour:13 minute:11 second:6 millisecond:10). 
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   566
    self assert:(t := Timestamp readFrom:'20-2-1995 13:11:06.001' format:'%day-%month-%year %h:%m:%s.%f' language:nil onError:[self error]
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   567
                ) = (Timestamp year:1995 month:2 day:20 hour:13 minute:11 second:6 millisecond:1). 
1927
ac82d7231d95 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1924
diff changeset
   568
1924
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   569
    self assert:(t := Timestamp readFrom:'20-2-1995 13:11:06.12345' format:'%day-%month-%year %h:%m:%s.%f' language:nil onError:[self error]
1927
ac82d7231d95 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1924
diff changeset
   570
                ) = (Timestamp year:1995 month:2 day:20 hour:13 minute:11 second:6 microsecond:123000). 
ac82d7231d95 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1924
diff changeset
   571
ac82d7231d95 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1924
diff changeset
   572
    self assert:(t := Timestamp readFrom:'20-2-1995 13:11:06.12345' format:'%day-%month-%year %h:%m:%s.%F' language:nil onError:[self error]
1924
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   573
                ) = (Timestamp year:1995 month:2 day:20 hour:13 minute:11 second:6 microsecond:123450). 
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   574
1927
ac82d7231d95 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1924
diff changeset
   575
    self assert:(t := Timestamp readFrom:'20-2-1995 13:11:06.12345678' format:'%day-%month-%year %h:%m:%s.%F' language:nil onError:[self error]
ac82d7231d95 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1924
diff changeset
   576
                ) = ((Timestamp year:1995 month:2 day:20 hour:13 minute:11 second:6)+123456780 nanoseconds). 
ac82d7231d95 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1924
diff changeset
   577
ac82d7231d95 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1924
diff changeset
   578
    self assert:(t := Timestamp readFrom:'20-2-1995 13:11:06.123456' format:'%day-%month-%year %h:%m:%s.%F' language:nil onError:[self error]
ac82d7231d95 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1924
diff changeset
   579
                ) = ((Timestamp year:1995 month:2 day:20 hour:13 minute:11 second:6)+123456 microseconds). 
ac82d7231d95 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1924
diff changeset
   580
ac82d7231d95 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1924
diff changeset
   581
    self assert:(t := Timestamp readFrom:'20-2-1995 13:11:06.123456789' format:'%day-%month-%year %h:%m:%s.%F' language:nil onError:[self error]
ac82d7231d95 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1924
diff changeset
   582
                ) = ((Timestamp year:1995 month:2 day:20 hour:13 minute:11 second:6)+123456789 nanoseconds). 
ac82d7231d95 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1924
diff changeset
   583
ac82d7231d95 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1924
diff changeset
   584
    self assert:(t := Timestamp readFrom:'20-2-1995 13:11:06.123456789012' format:'%day-%month-%year %h:%m:%s.%F' language:nil onError:[self error]
ac82d7231d95 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1924
diff changeset
   585
                ) = ((Timestamp year:1995 month:2 day:20 hour:13 minute:11 second:6)+123456789012 picoseconds). 
ac82d7231d95 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1924
diff changeset
   586
1886
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   587
    "
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   588
     self new test_01c_ReadingTimeStamps
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   589
    "
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   590
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
   591
    "Created: / 09-11-2017 / 10:19:19 / cg"
1992
5cfaf842bed0 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 1940
diff changeset
   592
    "Modified: / 27-07-2018 / 09:07:58 / Stefan Vogel"
365
b0d27286d78e *** empty log message ***
fm
parents: 346
diff changeset
   593
!
b0d27286d78e *** empty log message ***
fm
parents: 346
diff changeset
   594
1940
8e0e4fbf523d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1927
diff changeset
   595
test_01d_ReadingTimeStamps
8e0e4fbf523d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1927
diff changeset
   596
    |t|
8e0e4fbf523d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1927
diff changeset
   597
8e0e4fbf523d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1927
diff changeset
   598
    self assert:(t := Timestamp readFrom:'2017-11-09 10:18:03.236') printStringIso8601Format = '2017-11-09T10:18:03.236'.
8e0e4fbf523d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1927
diff changeset
   599
    self assert:(t isLocalTimestamp).
8e0e4fbf523d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1927
diff changeset
   600
    self assert:(t isUtcTimestamp not).
8e0e4fbf523d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1927
diff changeset
   601
    self assert:(t isTZTimestamp not).
8e0e4fbf523d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1927
diff changeset
   602
    
8e0e4fbf523d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1927
diff changeset
   603
    self assert:(t := Timestamp readFrom:'2017-11-09 10:18:03.236Z') printStringIso8601Format = '2017-11-09T10:18:03.236Z'.
8e0e4fbf523d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1927
diff changeset
   604
    self assert:(t isLocalTimestamp not).
8e0e4fbf523d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1927
diff changeset
   605
    self assert:(t isUtcTimestamp).
8e0e4fbf523d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1927
diff changeset
   606
    self assert:(t isTZTimestamp not).
8e0e4fbf523d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1927
diff changeset
   607
8e0e4fbf523d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1927
diff changeset
   608
    self should:[ Timestamp readFrom:'2017-11-09 10:18:03.236+1'] raise:Error.
8e0e4fbf523d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1927
diff changeset
   609
    self should:[ Timestamp readIso8601FormatFrom:'2017-11-09 10:18:03.236+1'] raise:TimeConversionError.
8e0e4fbf523d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1927
diff changeset
   610
    
8e0e4fbf523d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1927
diff changeset
   611
    self assert:(t := Timestamp readFrom:'2017-11-09 10:18:03.236+01') printStringIso8601Format = '2017-11-09T10:18:03.236+01'.
8e0e4fbf523d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1927
diff changeset
   612
    self assert:(t isLocalTimestamp not).
8e0e4fbf523d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1927
diff changeset
   613
    self assert:(t isUtcTimestamp not).
8e0e4fbf523d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1927
diff changeset
   614
    self assert:(t isTZTimestamp).
8e0e4fbf523d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1927
diff changeset
   615
8e0e4fbf523d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1927
diff changeset
   616
    "
8e0e4fbf523d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1927
diff changeset
   617
     self new test_01d_ReadingTimeStamps
8e0e4fbf523d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1927
diff changeset
   618
    "
8e0e4fbf523d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1927
diff changeset
   619
8e0e4fbf523d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1927
diff changeset
   620
    "Created: / 24-05-2018 / 17:45:08 / Claus Gittinger"
8e0e4fbf523d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1927
diff changeset
   621
!
8e0e4fbf523d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1927
diff changeset
   622
365
b0d27286d78e *** empty log message ***
fm
parents: 346
diff changeset
   623
test_02_ReadingDates
b0d27286d78e *** empty log message ***
fm
parents: 346
diff changeset
   624
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   625
     self assert:(Date
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   626
		    readFrom:'2-may-2010'
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   627
		    printFormat:'%d-%shortMonthName-%y'
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   628
		    language:'en'
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   629
		    onError:[self error]
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   630
		  ) = (Date newDay:2 month:5 year:2010).
365
b0d27286d78e *** empty log message ***
fm
parents: 346
diff changeset
   631
736
b51ba7f6c03f added: #test_03_calenderWeek
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
   632
    {
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   633
	{   '3-jan-2012'   .   (Date newDay:3 month:1 year:2012)    } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   634
	{   '15-feb-2012'   .   (Date newDay:15 month:2 year:2012)  } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   635
	{   '06-mar-2011'   .   (Date newDay:6 month:3 year:2011)   } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   636
	{   '19-apr-2013'   .   (Date newDay:19 month:4 year:2013)  } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   637
	{   '21-may-2015'   .   (Date newDay:21 month:5 year:2015)  } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   638
	{   '21-jun-2015'   .   (Date newDay:21 month:6 year:2015)  } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   639
	{   '21-jul-2015'   .   (Date newDay:21 month:7 year:2015)  } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   640
	{   '21-aug-2015'   .   (Date newDay:21 month:8 year:2015)  } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   641
	{   '21-sep-2015'   .   (Date newDay:21 month:9 year:2015)  } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   642
	{   '21-oct-2015'   .   (Date newDay:21 month:10 year:2015)  } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   643
	{   '21-nov-2015'   .   (Date newDay:21 month:11 year:2015)  } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   644
	{   '21-dec-2015'   .   (Date newDay:21 month:12 year:2015)  } .
736
b51ba7f6c03f added: #test_03_calenderWeek
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
   645
    } do:[:eachTestPair |
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   646
	 self assert:(Date
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   647
			readFrom:(eachTestPair first)
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   648
			printFormat:'%d-%shortMonthName-%y'
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   649
			language:'en'
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   650
			onError:[self error]
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   651
		      ) = (eachTestPair second).
736
b51ba7f6c03f added: #test_03_calenderWeek
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
   652
    ].
b51ba7f6c03f added: #test_03_calenderWeek
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
   653
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   654
     self assert:(Date
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   655
		    readFrom:'2-may-2010'
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   656
		    printFormat:'%d-%monthName-%y'
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   657
		    language:'en'
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   658
		    onError:[self error]
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   659
		  ) = (Date newDay:2 month:5 year:2010).
365
b0d27286d78e *** empty log message ***
fm
parents: 346
diff changeset
   660
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   661
     self assert:(Date
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   662
		    readFrom:'2-may-2010'
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   663
		    printFormat:'%d-%(shortMonthName)-%y'
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   664
		    language:'en'
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   665
		    onError:[self error]
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   666
		  ) = (Date newDay:2 month:5 year:2010).
366
e522392004b2 changed #'test_02_ReadingDates'
fm
parents: 365
diff changeset
   667
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   668
     self assert:(Date
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   669
		    readFrom:'2-may-2010'
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   670
		    printFormat:'%d-%(monthName)-%y'
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   671
		    language:'en'
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   672
		    onError:[self error]
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   673
		  ) = (Date newDay:2 month:5 year:2010).
366
e522392004b2 changed #'test_02_ReadingDates'
fm
parents: 365
diff changeset
   674
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   675
     self assert:(Date
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   676
		    readFrom:'2-5-2010'
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   677
		    printFormat:'%d-%m-%y'
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   678
		    onError:[self error]
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   679
		  ) = (Date newDay:2 month:5 year:2010).
365
b0d27286d78e *** empty log message ***
fm
parents: 346
diff changeset
   680
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   681
     self assert:(Date
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   682
		    readFrom:'5/2/2010'
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   683
		    printFormat:'%m/%d/%y'
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   684
		    onError:[self error]
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   685
		  ) = (Date newDay:2 month:5 year:2010).
365
b0d27286d78e *** empty log message ***
fm
parents: 346
diff changeset
   686
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   687
     self assert:(Date
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   688
		    readFrom:'2010-5-2'
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   689
		    printFormat:'%y-%m-%d'
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   690
		    onError:[self error]
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   691
		  ) = (Date newDay:2 month:5 year:2010).
365
b0d27286d78e *** empty log message ***
fm
parents: 346
diff changeset
   692
b0d27286d78e *** empty log message ***
fm
parents: 346
diff changeset
   693
    "
b0d27286d78e *** empty log message ***
fm
parents: 346
diff changeset
   694
     self new test_02_ReadingDates
b0d27286d78e *** empty log message ***
fm
parents: 346
diff changeset
   695
    "
736
b51ba7f6c03f added: #test_03_calenderWeek
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
   696
!
b51ba7f6c03f added: #test_03_calenderWeek
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
   697
1217
ee9044742185 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1077
diff changeset
   698
test_06_readingISO8601
ee9044742185 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1077
diff changeset
   699
    {
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   700
	{ '2004-W53-6'  . 'sat' . (Date newDay:1 month:1 year:2005) }   .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   701
	{ '2004-W53-7'  . 'sun' . (Date newDay:2 month:1 year:2005) }   .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   702
	{ '2005-W52-6'  . 'sat' . (Date newDay:31 month:12 year:2005) } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   703
	{ '2007-W01-1'  . 'mon' . (Date newDay:1 month:1 year:2007) }   .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   704
	{ '2007-W52-7'  . 'sun' . (Date newDay:30 month:12 year:2007) } .
1217
ee9044742185 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1077
diff changeset
   705
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   706
	{ '2008-W01-1'  . 'mon' . (Date newDay:31 month:12 year:2007) } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   707
	{ '2008-W01-2'  . 'tue' . (Date newDay:1 month:1 year:2008) }   .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   708
	{ '2008-W52-7'  . 'sun' . (Date newDay:28 month:12 year:2008) } .
1217
ee9044742185 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1077
diff changeset
   709
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   710
	{ '2009-W01-1'  . 'mon' . (Date newDay:29 month:12 year:2008) }     .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   711
	{ '2009-W01-2'  . 'tue' . (Date newDay:30 month:12 year:2008) }     .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   712
	{ '2009-W01-3'  . 'wed' . (Date newDay:31 month:12 year:2008) }     .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   713
	{ '2009-W01-4'  . 'thu' . (Date newDay:1 month:1 year:2009) }       .
1217
ee9044742185 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1077
diff changeset
   714
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   715
	{ '2009-W53-4'  . 'thu' . (Date newDay:31 month:12 year:2009) }     .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   716
	{ '2009-W53-5'  . 'fri' . (Date newDay:1 month:1 year:2010) }       .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   717
	{ '2009-W53-6'  . 'sat' . (Date newDay:2 month:1 year:2010) }       .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   718
	{ '2009-W53-7'  . 'sun' . (Date newDay:3 month:1 year:2010) }       .
1217
ee9044742185 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1077
diff changeset
   719
    } do:[:eachTriple |
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   720
	|input expected expectedDayName got gotName|
1217
ee9044742185 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1077
diff changeset
   721
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   722
	input := eachTriple first.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   723
	expectedDayName := eachTriple second.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   724
	expected := eachTriple third.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   725
	got := (Timestamp readIso8601FormatFrom:input onError:nil) asDate.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   726
	self assert:(got = expected) description:'wrong: ',input.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   727
	gotName := got abbreviatedDayNameForLanguage:#en.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   728
	self assert:gotName = expectedDayName description:'expected: ',expectedDayName asString,' got: ',gotName asString.
1217
ee9044742185 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1077
diff changeset
   729
    ]
ee9044742185 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1077
diff changeset
   730
ee9044742185 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1077
diff changeset
   731
    "
ee9044742185 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1077
diff changeset
   732
     self new test_06_calenderWeek_fails
ee9044742185 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1077
diff changeset
   733
    "
1219
369f5bac6379 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1218
diff changeset
   734
!
369f5bac6379 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1218
diff changeset
   735
369f5bac6379 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1218
diff changeset
   736
test_07_readingISO8601
1226
b5123dd5c3da class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   737
    "tests reading into a 'natural' timestamp - that is if there was a TZ info,
b5123dd5c3da class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   738
     that will be printed. If not, it will remain a local timestamp.
b5123dd5c3da class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   739
     Presenting timestamps this way is not usually a good idea, except for GUI
b5123dd5c3da class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   740
     (but not for data exchange)"
b5123dd5c3da class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   741
1219
369f5bac6379 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1218
diff changeset
   742
    {
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   743
     { '1995-02-20T13:11:06.123'   . '1995-02-20 13:11:06.123' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   744
     { '1995-02-20T13:11:06'       . '1995-02-20 13:11:06' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   745
     { '1995-02T13:11:06'          . '1995-02-01 13:11:06' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   746
     { '1995T13:11:06'             . '1995-01-01 13:11:06' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   747
     { '1995T13:11'                . '1995-01-01 13:11:00' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   748
     { '1995T13:11.5'              . '1995-01-01 13:11:30' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   749
     { '1995T13:11,5'              . '1995-01-01 13:11:30' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   750
     { '1995T13'                   . '1995-01-01 13:00:00' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   751
     { '1995T13.25'                . '1995-01-01 13:15:00' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   752
     { '1995T13.333333'            . '1995-01-01 13:19:59.999' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   753
     { '1995'                      . '1995-01-01 00:00:00' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   754
     { '1995-02'                   . '1995-02-01 00:00:00' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   755
     { '19950204'                  . '1995-02-04 00:00:00' } .
1219
369f5bac6379 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1218
diff changeset
   756
369f5bac6379 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1218
diff changeset
   757
     "/ day in year
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   758
     { '1995-001'                  . '1995-01-01 00:00:00' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   759
     { '1995-035'                  . '1995-02-04 00:00:00' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   760
     { '1995035'                   . '1995-02-04 00:00:00' } .
1219
369f5bac6379 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1218
diff changeset
   761
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   762
     { '1997-01-01'                . '1997-01-01 00:00:00' } .
1219
369f5bac6379 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1218
diff changeset
   763
     "/ week and weekday
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   764
     { '1997-W01'                  . '1996-12-30 00:00:00' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   765
     { '1997W01'                   . '1996-12-30 00:00:00' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   766
     { '1997W01-1'                 . '1996-12-30 00:00:00' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   767
     { '1997W011'                  . '1996-12-30 00:00:00' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   768
     { '1997W01'                   . '1996-12-30 00:00:00' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   769
     { '1997W01-2'                 . '1996-12-31 00:00:00' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   770
     { '1997-W01-2'                . '1996-12-31 00:00:00' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   771
     { '1997W012'                  . '1996-12-31 00:00:00' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   772
     { '2014W40'                   . '2014-09-29 00:00:00' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   773
     { '2014W44-4'                 . '2014-10-30 00:00:00' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   774
     { '2014W01'                   . '2013-12-30 00:00:00' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   775
     { '2014W01-1'                 . '2013-12-30 00:00:00' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   776
     { '2014W01-2'                 . '2013-12-31 00:00:00' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   777
     { '2014W01-3'                 . '2014-01-01 00:00:00' } .
1219
369f5bac6379 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1218
diff changeset
   778
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   779
     { '1995-02-20 13:11'          . '1995-02-20 13:11:00' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   780
     { '1995-02-20 1311'           . '1995-02-20 13:11:00' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   781
     { '1995-02-20 13'             . '1995-02-20 13:00:00' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   782
     { '1995-02-20 235959'         . '1995-02-20 23:59:59' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   783
     { '19950220 235959'           . '1995-02-20 23:59:59' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   784
     { '19950220 23:59:59.9942'    . '1995-02-20 23:59:59.994' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   785
     { '19950220 235959.9942'      . '1995-02-20 23:59:59.994' } .
1219
369f5bac6379 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1218
diff changeset
   786
369f5bac6379 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1218
diff changeset
   787
     "/ local vs. UTC
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   788
     { '1995-02-20 13:11:06'       . '1995-02-20 13:11:06' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   789
     { '1995-02-20 13:11:06Z'      . '1995-02-20 13:11:06Z' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   790
     { '1995-02-20 13:11:06+01'    . '1995-02-20 13:11:06+01' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   791
     { '1995-02-20 13:11:06+01:00' . '1995-02-20 13:11:06+01' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   792
     { '1995-02-20 13:11:06+01:30' . '1995-02-20 13:11:06+01:30' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   793
     { '1995-02-20 13:11:06+0130'  . '1995-02-20 13:11:06+01:30' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   794
     { '1995-02-20 13:11:06-01'    . '1995-02-20 13:11:06-01' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   795
     { '1995-02-20 13:11:06-01:00' . '1995-02-20 13:11:06-01' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   796
     { '1995-02-20 13:11:06-01:30' . '1995-02-20 13:11:06-01:30' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   797
     { '1995-02-20 13:11:06-0130'  . '1995-02-20 13:11:06-01:30' } .
1219
369f5bac6379 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1218
diff changeset
   798
369f5bac6379 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1218
diff changeset
   799
     "/ 24 is allowed with ISO, and is 00:00 of the next day:
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   800
     { '1995-02-20 24:00:00'       . '1995-02-21 00:00:00' } .
1219
369f5bac6379 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1218
diff changeset
   801
    } do:[:eachPair |
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   802
	|s1 t expected got|
1219
369f5bac6379 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1218
diff changeset
   803
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   804
	s1 := eachPair first.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   805
	t := Timestamp readIso8601FormatFrom:s1.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   806
	expected := eachPair second.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   807
	got := t asString.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   808
	self assert:(got = expected) description:'expected: ',expected,' got:',got.
1226
b5123dd5c3da class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   809
    ].
b5123dd5c3da class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   810
b5123dd5c3da class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   811
    "
b5123dd5c3da class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   812
     self new test_07_readingISO8601
b5123dd5c3da class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   813
    "
b5123dd5c3da class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   814
!
b5123dd5c3da class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   815
b5123dd5c3da class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   816
test_07b_readingISO8601UTC
b5123dd5c3da class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   817
    "tests reading into an utc timestamp"
b5123dd5c3da class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   818
b5123dd5c3da class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   819
    {
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   820
     { '1995-02-20T13:11:06.123'   . '1995-02-20 13:11:06.123Z' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   821
     { '1995-02-20T13:11:06'       . '1995-02-20 13:11:06Z' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   822
     { '1995-02T13:11:06'          . '1995-02-01 13:11:06Z' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   823
     { '1995T13:11:06'             . '1995-01-01 13:11:06Z' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   824
     { '1995T13:11'                . '1995-01-01 13:11:00Z' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   825
     { '1995T13:11.5'              . '1995-01-01 13:11:30Z' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   826
     { '1995T13:11,5'              . '1995-01-01 13:11:30Z' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   827
     { '1995T13'                   . '1995-01-01 13:00:00Z' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   828
     { '1995T13.25'                . '1995-01-01 13:15:00Z' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   829
     { '1995T13.333333'            . '1995-01-01 13:19:59.999Z' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   830
     { '1995'                      . '1995-01-01 00:00:00Z' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   831
     { '1995-02'                   . '1995-02-01 00:00:00Z' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   832
     { '19950204'                  . '1995-02-04 00:00:00Z' } .
1226
b5123dd5c3da class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   833
b5123dd5c3da class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   834
     "/ day in year
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   835
     { '1995-001'                  . '1995-01-01 00:00:00Z' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   836
     { '1995-035'                  . '1995-02-04 00:00:00Z' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   837
     { '1995035'                   . '1995-02-04 00:00:00Z' } .
1226
b5123dd5c3da class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   838
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   839
     { '1997-01-01'                . '1997-01-01 00:00:00Z' } .
1226
b5123dd5c3da class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   840
     "/ week and weekday
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   841
     { '1997-W01'                  . '1996-12-30 00:00:00Z' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   842
     { '1997W01'                   . '1996-12-30 00:00:00Z' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   843
     { '1997W01-1'                 . '1996-12-30 00:00:00Z' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   844
     { '1997W011'                  . '1996-12-30 00:00:00Z' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   845
     { '1997W01'                   . '1996-12-30 00:00:00Z' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   846
     { '1997W01-2'                 . '1996-12-31 00:00:00Z' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   847
     { '1997-W01-2'                . '1996-12-31 00:00:00Z' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   848
     { '1997W012'                  . '1996-12-31 00:00:00Z' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   849
     { '2014W40'                   . '2014-09-29 00:00:00Z' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   850
     { '2014W44-4'                 . '2014-10-30 00:00:00Z' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   851
     { '2014W01'                   . '2013-12-30 00:00:00Z' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   852
     { '2014W01-1'                 . '2013-12-30 00:00:00Z' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   853
     { '2014W01-2'                 . '2013-12-31 00:00:00Z' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   854
     { '2014W01-3'                 . '2014-01-01 00:00:00Z' } .
1226
b5123dd5c3da class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   855
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   856
     { '1995-02-20 13:11'          . '1995-02-20 13:11:00Z' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   857
     { '1995-02-20 1311'           . '1995-02-20 13:11:00Z' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   858
     { '1995-02-20 13'             . '1995-02-20 13:00:00Z' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   859
     { '1995-02-20 235959'         . '1995-02-20 23:59:59Z' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   860
     { '19950220 235959'           . '1995-02-20 23:59:59Z' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   861
     { '19950220 23:59:59.9942'    . '1995-02-20 23:59:59.994Z' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   862
     { '19950220 235959.9942'      . '1995-02-20 23:59:59.994Z' } .
1226
b5123dd5c3da class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   863
b5123dd5c3da class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   864
     "/ local vs. UTC
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   865
     { '1995-02-20 13:11:06'       . '1995-02-20 13:11:06Z' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   866
     { '1995-02-20 13:11:06Z'      . '1995-02-20 13:11:06Z' } .
1226
b5123dd5c3da class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   867
     { '1995-02-20 13:11:06+01'    . '1995-02-20 12:11:06Z' } .      "/ notice the changed time here!!!!!!
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   868
     { '1995-02-20 13:11:06+01:00' . '1995-02-20 12:11:06Z' } .      "/ notice the changed time here!!!!!!
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   869
     { '1995-02-20 13:11:06+01:30' . '1995-02-20 11:41:06Z' } .      "/ notice the changed time here!!!!!!
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   870
     { '1995-02-20 13:11:06+0130'  . '1995-02-20 11:41:06Z' } .      "/ notice the changed time here!!!!!!
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   871
     { '1995-02-20 13:11:06-01'    . '1995-02-20 14:11:06Z' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   872
     { '1995-02-20 13:11:06-01:00' . '1995-02-20 14:11:06Z' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   873
     { '1995-02-20 13:11:06-01:30' . '1995-02-20 14:41:06Z' } .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   874
     { '1995-02-20 13:11:06-0130'  . '1995-02-20 14:41:06Z' } .
1226
b5123dd5c3da class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   875
b5123dd5c3da class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   876
     "/ 24 is allowed with ISO, and is 00:00 of the next day:
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   877
     { '1995-02-20 24:00:00'       . '1995-02-21 00:00:00Z' } .
1226
b5123dd5c3da class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   878
    } do:[:eachPair |
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   879
	|s1 t expected got|
1226
b5123dd5c3da class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   880
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   881
	s1 := eachPair first.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   882
	t := UtcTimestamp readIso8601FormatFrom:s1.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   883
	expected := eachPair second.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   884
	got := t asString.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   885
	self assert:(got = expected) description:'expected: ',expected,' got:',got.
1219
369f5bac6379 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1218
diff changeset
   886
    ].
369f5bac6379 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1218
diff changeset
   887
369f5bac6379 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1218
diff changeset
   888
    "
369f5bac6379 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1218
diff changeset
   889
     self new test_07_readingISO8601
369f5bac6379 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1218
diff changeset
   890
    "
1220
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   891
!
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   892
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   893
test_08_readingISO8601_date
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   894
    "/ the old ISO8601Builder tests moved to here
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   895
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   896
    | ts reader |
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   897
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   898
    reader := Timestamp::TimestampISO8601Builder.
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   899
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   900
    ts := UtcTimestamp
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   901
	 year: 2005 month: 6 day: 15
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   902
	 hour: 0 minute: 0 second: 0 millisecond: 0.
1220
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   903
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   904
    "Test common dates"
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   905
    self assert: ts = (reader read: '20050615' withClass:UtcTimestamp).
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   906
    self assert: ts = (reader read: '2005-06-15'  withClass:UtcTimestamp).
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   907
    self assert: ts = (reader read: '05-06-15'  withClass:UtcTimestamp).
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   908
    self assert: ts = (reader read: '05-0615'  withClass:UtcTimestamp). "/ Is this correct?
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   909
    self assert: ts = (reader read: ':50615'  withClass:UtcTimestamp). "/ Should not happen and should not appear after 2009
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   910
    self assert: ts = (reader read: '200506-15'  withClass:UtcTimestamp). "/ Is this corect?
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   911
    self assert: ts = (reader read: '105-06-15'  withClass:UtcTimestamp). "/ Should not happen
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   912
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   913
    "Test week numbers"
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   914
    self assert: ts = (reader read: '05W243'  withClass:UtcTimestamp).
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   915
    self assert: ts = (reader read: '2005W24-3'  withClass:UtcTimestamp).
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   916
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   917
    "Test day numbers"
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   918
    self assert: ts = (reader read: '2005-166'  withClass:UtcTimestamp).
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   919
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   920
    ts := UtcTimestamp year: 2004 month: 12 day: 31 hour: 0 minute: 0 second: 0 millisecond: 0.
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   921
    self assert: ts = (reader read: '2004-366'  withClass:UtcTimestamp).
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   922
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   923
    ts := UtcTimestamp year: 2005 month: 12 day: 31 hour: 0 minute: 0 second: 0 millisecond: 0.
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   924
    self assert: ts = (reader read: '2005-365'  withClass:UtcTimestamp).
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   925
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   926
    "Test february"
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   927
    ts := UtcTimestamp year: 2000 month: 2 day: 28 hour: 0 minute: 0 second: 0 millisecond: 0.
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   928
    self assert: ts = (reader read: '20000228'  withClass:UtcTimestamp).
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   929
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   930
    ts := UtcTimestamp year: 2000 month: 2 day: 29 hour: 0 minute: 0 second: 0 millisecond: 0.
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   931
    self assert: ts = (reader read: '20000229'  withClass:UtcTimestamp).
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   932
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   933
    "
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   934
     self new test_08_readingISO8601
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   935
    "
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   936
!
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   937
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   938
test_09_readingISO8601_edge
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   939
    "/ the old ISO8601Builder tests moved to here
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   940
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   941
    | ts reader |
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   942
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   943
    reader := Timestamp::TimestampISO8601Builder.
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   944
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   945
    self should: [reader read: '20050229' withClass:UtcTimestamp] raise:ConversionError.
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   946
    self should: [reader read: '20050029' withClass:UtcTimestamp] raise:ConversionError.
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   947
    self should: [reader read: '20050332' withClass:UtcTimestamp] raise:ConversionError.
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   948
    self should: [reader read: '2005-366' withClass:UtcTimestamp] raise:ConversionError.
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   949
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   950
    ts := UtcTimestamp year: 2005 month: 1 day: 1 hour: 0 minute: 0 second: 0 millisecond: 0.
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   951
    self assert: ts = (reader read: '20041231T22-0200' withClass:UtcTimestamp).
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   952
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   953
    ts := UtcTimestamp year: 2004 month: 12 day: 31 hour: 22 minute: 0 second: 0 millisecond: 0.
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   954
    self assert: ts = (reader read: '20050101T0000+0200' withClass:UtcTimestamp).
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   955
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   956
    "
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   957
     self new test_08_readingISO8601
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   958
    "
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   959
!
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   960
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   961
test_10_readingISO8601_time
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   962
    "/ the old ISO8601Builder tests moved to here
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   963
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   964
    | ts reader |
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   965
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   966
    reader := Timestamp::TimestampISO8601Builder.
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   967
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   968
    ts := UtcTimestamp  year: 2005 month: 6 day: 15 hour: 17 minute: 37 second: 0 millisecond: 0.
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   969
    self assert: ts = (reader read: '2005-06-15 17:37' withClass:UtcTimestamp).
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   970
    self assert: ts = (reader read: '20050615T1737' withClass:UtcTimestamp).
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   971
    self assert: ts = (reader read: '05-0615T17:3700' withClass:UtcTimestamp).
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   972
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   973
    ts := UtcTimestamp  year: 2005 month: 6 day: 15 hour: 17 minute: 37 second: 0 millisecond: 30.
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   974
    self assert: ts = (reader read: '05-0615T17:3700.03' withClass:UtcTimestamp).
1924
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   975
    self assert: ts = (reader read: '2005-06-15T17:37:00.030' withClass:UtcTimestamp).
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   976
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   977
    ts := UtcTimestamp  year: 2005 month: 6 day: 15 hour: 17 minute: 37 second: 0 microsecond:300.
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   978
    self assert: ts = (reader read: '05-0615T17:3700.0003' withClass:UtcTimestamp).
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
   979
    self assert: ts = (reader read: '2005-06-15T17:37:00.0003-00:00' withClass:UtcTimestamp).
1220
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   980
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   981
    "
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   982
     self new test_10_readingISO8601_time
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   983
    "
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   984
!
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   985
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   986
test_11_readingISO8601_timezone
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   987
    "/ the old ISO8601Builder tests moved to here
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   988
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   989
    | ts reader |
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   990
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   991
    reader := Timestamp::TimestampISO8601Builder.
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   992
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   993
    ts := UtcTimestamp
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   994
	 year: 2005 month: 6 day: 15
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   995
	 hour: 17 minute: 37 second: 0 millisecond: 0.
1220
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   996
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   997
    self assert: ts = (reader read: '2005-06-15T17:37Z' withClass:UtcTimestamp).
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   998
    self assert: ts = (reader read: '2005-06-15T17:37+0000' withClass:UtcTimestamp).
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   999
    self assert: ts = (reader read: '2005-06-15T17:37-00:00' withClass:UtcTimestamp).
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
  1000
    self assert: ts = (reader read: '2005-06-15T15:37:00-0200' withClass:UtcTimestamp).
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
  1001
    self assert: ts = (reader read: '2005-06-15T19:37:00+0200'withClass:UtcTimestamp).
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
  1002
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
  1003
    "
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
  1004
     self new test_11_readingISO8601_timezone
e8277d9a8677 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
  1005
    "
1222
b476e1efa7f1 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1220
diff changeset
  1006
!
b476e1efa7f1 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1220
diff changeset
  1007
1244
850ca3a30a23 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
  1008
test_16_readingOtherFormats
850ca3a30a23 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
  1009
    | ts |
850ca3a30a23 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
  1010
850ca3a30a23 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
  1011
    "/ european format
850ca3a30a23 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
  1012
    ts := Timestamp readFrom: '16-09-2013 00:42:35' readStream.
850ca3a30a23 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
  1013
850ca3a30a23 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
  1014
    self assert: ts day = 16.
850ca3a30a23 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
  1015
    self assert: ts month = 9.
850ca3a30a23 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
  1016
    self assert: ts year = 2013.
850ca3a30a23 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
  1017
    self assert: ts hours = 0.
850ca3a30a23 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
  1018
    self assert: ts minutes = 42.
850ca3a30a23 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
  1019
    self assert: ts seconds = 35.
850ca3a30a23 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
  1020
850ca3a30a23 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
  1021
    "/ us format
850ca3a30a23 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
  1022
    ts := Timestamp readFrom: '11/21/2013 00:42:35' readStream.
850ca3a30a23 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
  1023
850ca3a30a23 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
  1024
    self assert: ts day = 21.
850ca3a30a23 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
  1025
    self assert: ts month = 11.
850ca3a30a23 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
  1026
    self assert: ts year = 2013.
850ca3a30a23 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
  1027
    self assert: ts hours = 0.
850ca3a30a23 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
  1028
    self assert: ts minutes = 42.
850ca3a30a23 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
  1029
    self assert: ts seconds = 35.
850ca3a30a23 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
  1030
850ca3a30a23 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
  1031
    "
850ca3a30a23 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
  1032
     self new test_16_readingOtherFormats
850ca3a30a23 class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
  1033
    "
1886
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
  1034
!
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
  1035
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
  1036
test_17_readingBrokenStrings
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
  1037
    "endless loop happened with:
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
  1038
        Timestamp readFrom:'0' onError:#foo
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
  1039
    "
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
  1040
    
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
  1041
    #(
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
  1042
        ''
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
  1043
        '0'
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
  1044
        '1'
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
  1045
        '1-'
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
  1046
        '1-1'
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
  1047
        '1-1-'
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
  1048
        '1-1-1 10'
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
  1049
        '0-0-0'
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
  1050
    ) do:[:eachBadString |    
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
  1051
        | ts |
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
  1052
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
  1053
        "/ should not run into an endless loop
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
  1054
        [
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
  1055
            ts := Timestamp readFrom:eachBadString onError:#foo.
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
  1056
        ] valueWithTimeout:(50 milliseconds).
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
  1057
    
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
  1058
        self assert: (ts notNil) description:'timestamp reading leads to endless loop'.
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
  1059
        self assert: ts == #foo.
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
  1060
    ].
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
  1061
    
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
  1062
    "
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
  1063
     self new test_17_readingBrokenStrings
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
  1064
    "
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
  1065
6deb0e9fa0d2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1652
diff changeset
  1066
    "Created: / 09-11-2017 / 10:00:30 / cg"
1924
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
  1067
!
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
  1068
2330
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  1069
test_21_readingDateInVariousFormats
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  1070
    {
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  1071
        '1.1.1990' . '%d %m %y' . (Date year:1990 month:1 day:1 ) .
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  1072
        '1.1.2090' . '%d %m %y' . (Date year:2090 month:1 day:1 ) .
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  1073
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  1074
        '1.1.49' . '%d %m %(Y1950)' . (Date year:2049 month:1 day:1 ) .
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  1075
        '1.1.50' . '%d %m %(Y1950)' . (Date year:1950 month:1 day:1 ) .
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  1076
        '1.1.51' . '%d %m %(Y1950)' . (Date year:1951 month:1 day:1 ) .
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  1077
        '1.1.99' . '%d %m %(Y1950)' . (Date year:1999 month:1 day:1 ) .
1924
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
  1078
2330
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  1079
        '1.1.69' . '%d %m %(Y1970)' . (Date year:2069 month:1 day:1 ) .
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  1080
        '1.1.70' . '%d %m %(Y1970)' . (Date year:1970 month:1 day:1 ) .
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  1081
        '1.1.71' . '%d %m %(Y1970)' . (Date year:1971 month:1 day:1 ) .
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  1082
        '1.1.99' . '%d %m %(Y1970)' . (Date year:1999 month:1 day:1 ) .
1924
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
  1083
2330
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  1084
        '1.1.79' . '%d %m %(Y1980)' . (Date year:2079 month:1 day:1 ) .
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  1085
        '1.1.80' . '%d %m %(Y1980)' . (Date year:1980 month:1 day:1 ) .
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  1086
        '1.1.81' . '%d %m %(Y1980)' . (Date year:1981 month:1 day:1 ) .
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  1087
        '1.1.99' . '%d %m %(Y1980)' . (Date year:1999 month:1 day:1 ) .
1924
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
  1088
2330
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  1089
        '1.1.49' . '%d %m %(Y1900)' . (Date year:1949 month:1 day:1 ) .
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  1090
        '1.1.69' . '%d %m %(Y1900)' . (Date year:1969 month:1 day:1 ) .
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  1091
        '1.1.79' . '%d %m %(Y1900)' . (Date year:1979 month:1 day:1 ) .
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  1092
        '1.1.80' . '%d %m %(Y1900)' . (Date year:1980 month:1 day:1 ) .
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  1093
        '1.1.81' . '%d %m %(Y1900)' . (Date year:1981 month:1 day:1 ) .
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  1094
        '1.1.99' . '%d %m %(Y1900)' . (Date year:1999 month:1 day:1 ) .
1924
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
  1095
2330
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  1096
        '1.1.49' . '%d %m %(Y2000)' . (Date year:2049 month:1 day:1 ) .
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  1097
        '1.1.69' . '%d %m %(Y2000)' . (Date year:2069 month:1 day:1 ) .
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  1098
        '1.1.79' . '%d %m %(Y2000)' . (Date year:2079 month:1 day:1 ) .
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  1099
        '1.1.80' . '%d %m %(Y2000)' . (Date year:2080 month:1 day:1 ) .
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  1100
        '1.1.81' . '%d %m %(Y2000)' . (Date year:2081 month:1 day:1 ) .
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  1101
        '1.1.99' . '%d %m %(Y2000)' . (Date year:2099 month:1 day:1 ) .
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  1102
    } inGroupsOf:3 do:[:str :fmt :expected |    
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  1103
        | result |
1924
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
  1104
2330
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  1105
        result := Date readFrom:str format:fmt onError:#foo.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  1106
    
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  1107
        self assert: result = expected.
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  1108
    ].
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  1109
    
1924
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
  1110
    "
2330
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  1111
     self new test_21_readingDateInVariousFormats
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  1112
    "
1924
cc644916d874 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1886
diff changeset
  1113
2330
c7cb74c4ed7b #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1992
diff changeset
  1114
    "Created: / 09-11-2017 / 10:00:30 / cg"
346
b2a1db91f556 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1115
! !
b2a1db91f556 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1116
b2a1db91f556 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1117
!TimeAndDateTest class methodsFor:'documentation'!
b2a1db91f556 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1118
b2a1db91f556 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1119
version
b2a1db91f556 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1120
    ^ '$Header$'
737
06d8d2821c46 changed: #test_03_calenderWeek
Claus Gittinger <cg@exept.de>
parents: 736
diff changeset
  1121
!
06d8d2821c46 changed: #test_03_calenderWeek
Claus Gittinger <cg@exept.de>
parents: 736
diff changeset
  1122
06d8d2821c46 changed: #test_03_calenderWeek
Claus Gittinger <cg@exept.de>
parents: 736
diff changeset
  1123
version_CVS
06d8d2821c46 changed: #test_03_calenderWeek
Claus Gittinger <cg@exept.de>
parents: 736
diff changeset
  1124
    ^ '$Header$'
346
b2a1db91f556 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1125
! !
1077
9cb704988db8 category change
Claus Gittinger <cg@exept.de>
parents: 745
diff changeset
  1126