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