author | sr |
Wed, 05 Feb 2020 14:14:49 +0100 | |
changeset 2555 | b3fd3a67477b |
parent 2391 | c4bfc248aace |
permissions | -rw-r--r-- |
2391 | 1 |
"{ Encoding: utf8 }" |
2 |
||
1447 | 3 |
"{ Package: 'stx:goodies/regression' }" |
346 | 4 |
|
5 |
"{ NameSpace: RegressionTests }" |
|
6 |
||
7 |
TestCase subclass:#TimeAndDateTest |
|
8 |
instanceVariableNames:'' |
|
9 |
classVariableNames:'' |
|
10 |
poolDictionaries:'' |
|
1077 | 11 |
category:'tests-Regression-DateAndTime' |
346 | 12 |
! |
13 |
||
14 |
||
15 |
!TimeAndDateTest methodsFor:'Testing'! |
|
16 |
||
2330 | 17 |
test_03_calenderWeek |
18 |
self assert:(Date newDay:5 month:11 year:2012) weekInYear == 45. |
|
19 |
self assert:(Date newDay:11 month:11 year:2012) weekInYear == 45. |
|
20 |
||
21 |
self assert:(Date newDay:4 month:11 year:2012) weekInYear == 44. |
|
22 |
self assert:(Date newDay:12 month:11 year:2012) weekInYear == 46. |
|
23 |
||
24 |
self assert:(Date newDay:29 month:12 year:2014) weekInYear == 1. "/ YES!! |
|
25 |
self assert:(Date newDay:30 month:12 year:2014) weekInYear == 1. "/ YES!! |
|
26 |
self assert:(Date newDay:31 month:12 year:2014) weekInYear == 1. "/ YES!! |
|
27 |
self assert:(Date newDay:1 month:1 year:2015) weekInYear == 1. |
|
28 |
self assert:(Date newDay:2 month:1 year:2015) weekInYear == 1. |
|
29 |
self assert:(Date newDay:3 month:1 year:2015) weekInYear == 1. |
|
30 |
self assert:(Date newDay:4 month:1 year:2015) weekInYear == 1. |
|
31 |
||
32 |
self assert:(Date newDay:5 month:1 year:2015) weekInYear == 2. |
|
33 |
||
34 |
"/ every 4th of january is in the 1st week |
|
35 |
1902 to:2100 do:[:y | |
|
36 |
|d| |
|
37 |
d := Date newDay:4 month:1 year:y. |
|
38 |
self assert:d weekInYear == 1. |
|
39 |
]. |
|
40 |
||
41 |
" |
|
42 |
self new test_03_calenderWeek |
|
43 |
" |
|
44 |
! |
|
45 |
||
46 |
test_04_calenderWeek_fails |
|
47 |
<test: broken> |
|
48 |
^ self. |
|
49 |
"/ currently fails for date before 1901 |
|
50 |
1900 to:1905 do:[:y | |
|
51 |
|d| |
|
52 |
d := Date newDay:4 month:1 year:y. |
|
53 |
self assert:d weekInYear == 1. |
|
54 |
]. |
|
55 |
||
56 |
" |
|
57 |
self new test_04_calenderWeek_fails |
|
58 |
" |
|
59 |
! |
|
60 |
||
61 |
test_05_weekDayConversion |
|
62 |
{ |
|
63 |
{ #( 6 53 2004) "2004-W53-6" . (Date newDay:1 month:1 year:2005) } . |
|
64 |
{ #( 7 53 2004) "2004-W53-7" . (Date newDay:2 month:1 year:2005) } . |
|
65 |
{ #( 6 52 2005) "2005-W52-6" . (Date newDay:31 month:12 year:2005) } . |
|
66 |
{ #( 1 1 2007) "2007-W01-1" . (Date newDay:1 month:1 year:2007) } . |
|
67 |
{ #( 7 52 2007) "2007-W52-7" . (Date newDay:30 month:12 year:2007) } . |
|
68 |
||
69 |
{ #( 1 1 2008) "2008-W01-1" . (Date newDay:31 month:12 year:2007) } . |
|
70 |
{ #( 2 1 2008) "2008-W01-2" . (Date newDay:1 month:1 year:2008) } . |
|
71 |
{ #( 7 52 2008) "2008-W52-7" . (Date newDay:28 month:12 year:2008) } . |
|
72 |
||
73 |
{ #( 1 1 2009) "2009-W01-1" . (Date newDay:29 month:12 year:2008) } . |
|
74 |
{ #( 2 1 2009) "2009-W01-2" . (Date newDay:30 month:12 year:2008) } . |
|
75 |
{ #( 3 1 2009) "2009-W01-3" . (Date newDay:31 month:12 year:2008) } . |
|
76 |
{ #( 4 1 2009) "2009-W01-4" . (Date newDay:1 month:1 year:2009) } . |
|
77 |
||
78 |
{ #( 4 53 2009) "2009-W53-4" . (Date newDay:31 month:12 year:2009) } . |
|
79 |
{ #( 5 53 2009) "2009-W53-5" . (Date newDay:1 month:1 year:2010) } . |
|
80 |
{ #( 6 53 2009) "2009-W53-6" . (Date newDay:2 month:1 year:2010) } . |
|
81 |
{ #( 7 53 2009) "2009-W53-7" . (Date newDay:3 month:1 year:2010) } . |
|
82 |
||
83 |
{ #( 1 1 1997) "1997-W01-1" . (Date newDay:30 month:12 year:1996) } . |
|
84 |
} do:[:eachPair | |
|
85 |
|dwy d1 d2 dayInWeek weekNr year| |
|
86 |
||
87 |
dwy := eachPair first. |
|
88 |
dayInWeek := dwy first. |
|
89 |
weekNr := dwy second. |
|
90 |
year := dwy third. |
|
91 |
d1 := Date newDayInWeek:dayInWeek week:weekNr year:year. |
|
92 |
||
93 |
d2 := eachPair second. |
|
94 |
self assert:(d1 = d2) description:'wrong: ',d1 printString, ' vs. ',d2 printString. |
|
95 |
self assert:(d1 weekInYear == weekNr). |
|
96 |
self assert:(d1 dayInWeek == dayInWeek). |
|
97 |
] |
|
98 |
||
99 |
" |
|
100 |
self new test_05_weekDayConversion |
|
101 |
" |
|
102 |
! |
|
103 |
||
104 |
test_12_dateQueries |
|
105 |
|d1 d2 d3| |
|
106 |
||
107 |
d1 := Date newDay:1 month:2 year:1940. |
|
108 |
d2 := Date newDay:1 month:2 year:1941. |
|
109 |
self assert:(d2 - d1) = 366. |
|
110 |
||
111 |
d1 := Date newDay:1 month:2 year:1840. |
|
112 |
d2 := Date newDay:1 month:2 year:1841. |
|
113 |
self assert:(d2 - d1) = 366. |
|
114 |
self assert:(d1 addDays:366) = d2. |
|
115 |
||
116 |
Date leapYear:1540. |
|
117 |
d1 := Date newDay:1 month:2 year:1540. |
|
118 |
d2 := Date newDay:1 month:2 year:1541. |
|
119 |
self assert:(d2 - d1) = 366. |
|
120 |
||
121 |
d1 := Date newDay:1 year:1901. |
|
122 |
self assert:(d1 day = 1). |
|
123 |
self assert:(d1 month = 1). |
|
124 |
self assert:(d1 year = 1901). |
|
125 |
||
126 |
"/ 1900 was NOT a leap year |
|
127 |
self assert:(Date leapYear:1900) not. |
|
128 |
"/ 2000 was a leap year |
|
129 |
self assert:(Date leapYear:2000). |
|
130 |
||
131 |
d2 := d1 subtractDays:365. |
|
132 |
self assert:(d2 day = 1). |
|
133 |
self assert:(d2 month = 1). |
|
134 |
self assert:(d2 year = 1900). |
|
135 |
||
136 |
d3 := d2 subtractDays:365. |
|
137 |
self assert:(d3 day = 1). |
|
138 |
self assert:(d3 month = 1). |
|
139 |
self assert:(d3 year = 1899). |
|
140 |
||
141 |
d1 := Date newDay:1 month:2 year:2540. |
|
142 |
d2 := Date newDay:1 month:2 year:2541. |
|
143 |
self assert:(d2 - d1) = 366. |
|
144 |
||
145 |
||
146 |
" |
|
147 |
self new test_12_dateQueries |
|
148 |
" |
|
149 |
! |
|
150 |
||
151 |
test_13_timestampQueries |
|
152 |
|d1 d2 local utc| |
|
153 |
||
154 |
d1 := UtcTimestamp year:2000 month:1 day:1. |
|
155 |
d2 := UtcTimestamp year:2001 month:1 day:1. |
|
156 |
self assert:(d2 - d1) days = 366. |
|
157 |
||
158 |
d1 := UtcTimestamp year:1940 month:1 day:2. |
|
159 |
d2 := UtcTimestamp year:1941 month:1 day:2. |
|
160 |
self assert:d1 asDate year = 1940. |
|
161 |
self assert:d2 asDate year = 1941. |
|
162 |
self assert:d1 asDate month = 1. |
|
163 |
self assert:d2 asDate month = 1. |
|
164 |
self assert:d1 asDate day = 2. |
|
165 |
self assert:d2 asDate day = 2. |
|
166 |
||
167 |
self assert:d1 asDate isLeapYear. |
|
168 |
self assert:d2 asDate isLeapYear not. |
|
169 |
self assert:(d2 - d1) days = 366. |
|
170 |
||
171 |
d1 := UtcTimestamp year:1840 month:1 day:1. |
|
172 |
d2 := UtcTimestamp year:1841 month:1 day:1. |
|
173 |
self assert:d1 asDate isLeapYear. |
|
174 |
self assert:d2 asDate isLeapYear not. |
|
175 |
self assert:(d2 - d1) days = 366. |
|
176 |
||
177 |
self assert:(d1 addDays:366) = d2. |
|
178 |
||
179 |
d1 := UtcTimestamp year:1540 month:1 day:1. |
|
180 |
d2 := UtcTimestamp year:1541 month:1 day:1. |
|
181 |
self assert:d1 asDate isLeapYear. |
|
182 |
self assert:d2 asDate isLeapYear not. |
|
183 |
self assert:(d2 - d1) days = 366. |
|
184 |
||
185 |
d1 := UtcTimestamp year:2038 month:1 day:1. |
|
186 |
d2 := UtcTimestamp year:2039 month:1 day:1. |
|
187 |
self assert:d1 asDate isLeapYear not. |
|
188 |
self assert:d2 asDate isLeapYear not. |
|
189 |
self assert:(d2 - d1) days = 365. |
|
190 |
||
191 |
d1 := UtcTimestamp year:2540 month:1 day:1. |
|
192 |
d2 := UtcTimestamp year:2541 month:1 day:1. |
|
193 |
self assert:d1 asDate isLeapYear. |
|
194 |
self assert:d2 asDate isLeapYear not. |
|
195 |
self assert:(d2 - d1) days = 366. |
|
196 |
||
197 |
d1 := UtcTimestamp year:3540 month:1 day:1. |
|
198 |
d2 := UtcTimestamp year:3541 month:1 day:1. |
|
199 |
self assert:d1 asDate isLeapYear. |
|
200 |
self assert:d2 asDate isLeapYear not. |
|
201 |
self assert:(d2 - d1) days = 366. |
|
202 |
||
203 |
d1 := UtcTimestamp year:1969 month:1 day:1. |
|
204 |
d2 := UtcTimestamp year:1970 month:1 day:1. |
|
205 |
self assert:d1 asDate isLeapYear not. |
|
206 |
self assert:d2 asDate isLeapYear not. |
|
207 |
self assert:(d2 - d1) days = 365. |
|
208 |
||
209 |
d1 := UtcTimestamp year:1600 month:1 day:1. |
|
210 |
d2 := UtcTimestamp year:1601 month:1 day:1. |
|
211 |
self assert:d1 asDate isLeapYear. |
|
212 |
self assert:d2 asDate isLeapYear not. |
|
213 |
self assert:(d2 - d1) days = 366. |
|
214 |
||
215 |
"/ local time vs. utc time |
|
216 |
local := Timestamp year:1940 month:1 day:1. |
|
217 |
utc := UtcTimestamp year:1940 month:1 day:1. |
|
218 |
self assert:(local asUtcTimestamp - utc asUtcTimestamp) asSeconds = local utcOffset. |
|
219 |
||
220 |
"/ tz time vs. utc time |
|
221 |
utc := Timestamp readFrom:'20000102T123000Z'. |
|
222 |
local := Timestamp readFrom:'20000102T123000+02'. |
|
223 |
self assert:(utc - local) asSeconds = 7200. |
|
224 |
||
225 |
"/ tz time vs. utc time |
|
226 |
utc := UtcTimestamp readFrom:'20000102T123000Z'. |
|
227 |
local := UtcTimestamp readFrom:'20000102T123000-02'. |
|
228 |
self assert:(utc - local) asSeconds = -7200. |
|
229 |
||
230 |
" |
|
231 |
self new test_13_timestampQueries |
|
232 |
" |
|
233 |
||
234 |
"Modified: / 27-07-2018 / 09:59:25 / Stefan Vogel" |
|
235 |
! |
|
236 |
||
237 |
test_14_arithmetic |
|
238 |
|t1 t2 t3 s| |
|
239 |
||
240 |
t1 := UtcTimestamp newDay:1 month:1 year:2000. |
|
241 |
t2 := t1 addDays:1. |
|
242 |
self assert:(t2 - t1) days = 1. |
|
243 |
||
244 |
t2 := t1 addHours:1. |
|
245 |
self assert:(t2 - t1) hours = 1. |
|
246 |
||
247 |
t2 := t1 addSeconds:1. |
|
248 |
self assert:(t2 - t1) seconds = 1. |
|
249 |
||
250 |
t1 := UtcTimestamp readFrom:'20000102T133045Z'. |
|
251 |
t2 := t1 addDays:1. |
|
252 |
self assert:(t2 printString = '2000-01-03 13:30:45Z'). |
|
253 |
||
254 |
t1 := Timestamp readFrom:'20000102T133045+01'. |
|
255 |
t2 := t1 addDays:1. |
|
256 |
self assert:(t2 printString = '2000-01-03 13:30:45+01'). |
|
257 |
||
258 |
t1 := UtcTimestamp readFrom:'20000102T133045Z'. |
|
259 |
t2 := Timestamp readFrom:'20000102T133045Z'. |
|
260 |
self assert:(t1 = t2). |
|
261 |
||
262 |
t2 := Timestamp readFrom:'20000102T143045+01'. |
|
263 |
self assert:(t1 = t2). |
|
264 |
||
265 |
t2 := Timestamp readFrom:'20000102T123045-01'. |
|
266 |
self assert:(t1 = t2). |
|
267 |
||
268 |
t2 := Timestamp readFrom:'20000102T123045'. "/ a local one |
|
269 |
s := t2 storeString. |
|
270 |
t3 := Timestamp readFrom:s. |
|
271 |
||
272 |
self assert:(t2 = t3). |
|
273 |
||
274 |
t1 := TZTimestamp readFrom:'20000102T133045Z'. |
|
275 |
self assert:(t1 printString = '2000-01-02 13:30:45+00'). |
|
276 |
t1 := UtcTimestamp readFrom:'20000102T133045Z'. |
|
277 |
self assert:(t1 printString = '2000-01-02 13:30:45Z'). |
|
278 |
||
279 |
" |
|
280 |
self new test_14_arithmetic |
|
281 |
" |
|
282 |
! |
|
283 |
||
284 |
test_15_misc |
|
285 |
#( 1700 1800 1900 2100 2200 ) do:[:y | |
|
286 |
self assert:(Date leapYear:y) not |
|
287 |
]. |
|
288 |
#( 1600 2000 2400 ) do:[:y | |
|
289 |
self assert:(Date leapYear:y) |
|
290 |
]. |
|
291 |
||
292 |
" |
|
293 |
self new test_15_misc |
|
294 |
" |
|
295 |
! |
|
296 |
||
297 |
test_18_moreTimestampArithmetic |
|
298 |
|t1 t2| |
|
299 |
||
300 |
t1 := Timestamp year:2000 month:1 day:1. |
|
301 |
t2 := t1 addMilliseconds:1. |
|
302 |
self assert:t1 seconds = 0. |
|
303 |
self assert:t2 seconds = 0. |
|
304 |
self assert:t1 exactSeconds = 0. |
|
305 |
self assert:t2 exactSeconds = 0.001. |
|
306 |
self assert:t1 milliseconds = 0. |
|
307 |
self assert:t2 milliseconds = 1. |
|
308 |
self assert:t1 microseconds = 0. |
|
309 |
self assert:t2 microseconds = 1000. |
|
310 |
self assert:t1 nanoseconds = 0. |
|
311 |
self assert:t2 nanoseconds = 1000000. |
|
312 |
self assert:t1 picoseconds = 0. |
|
313 |
self assert:t2 picoseconds = 1000000000. |
|
314 |
||
315 |
self assert:(t2 - t1) milliseconds = 1. |
|
316 |
self assert:(t2 - t1) microseconds = 1000. |
|
317 |
self assert:(t2 - t1) nanoseconds = 1000000. |
|
318 |
self assert:(t2 - t1) picoseconds = 1000000000. |
|
319 |
||
320 |
" |
|
321 |
self new test_18_moreArithmetic |
|
322 |
" |
|
323 |
! |
|
324 |
||
325 |
test_19_comparing |
|
326 |
|t1 t2| |
|
327 |
||
328 |
t1 := Time now. |
|
329 |
t2 := t1 addMilliseconds:1. |
|
330 |
||
331 |
self assert:t2 > t1. |
|
332 |
self assert:t2 >= t1. |
|
333 |
self assert:(t2 = t1) not. |
|
334 |
self assert:(t2 <= t1) not. |
|
335 |
self assert:(t2 < t1) not. |
|
336 |
||
337 |
t1 := Time now. |
|
338 |
t2 := t1 subtractMilliseconds:1. |
|
339 |
||
340 |
self assert:t2 < t1. |
|
341 |
self assert:t2 <= t1. |
|
342 |
self assert:(t2 = t1) not. |
|
343 |
self assert:(t2 >= t1) not. |
|
344 |
self assert:(t2 > t1) not. |
|
345 |
||
346 |
t1 := Time now. |
|
347 |
t2 := t1 + 1 milliseconds. |
|
348 |
self assert:t2 = (t1 addMilliseconds:1). |
|
349 |
||
350 |
t2 := t1 - 1 milliseconds. |
|
351 |
self assert:t2 = (t1 addMilliseconds:-1). |
|
352 |
self assert:t2 = (t1 subtractMilliseconds:1). |
|
353 |
||
354 |
" |
|
355 |
self new test_19_comparing |
|
356 |
" |
|
357 |
! |
|
358 |
||
359 |
test_20_comparing |
|
360 |
|t1 t2| |
|
361 |
||
362 |
t1 := Timestamp now. |
|
363 |
t2 := t1 addMilliseconds:1. |
|
364 |
||
365 |
self assert:t2 > t1. |
|
366 |
self assert:t2 >= t1. |
|
367 |
self assert:(t2 = t1) not. |
|
368 |
self assert:(t2 <= t1) not. |
|
369 |
self assert:(t2 < t1) not. |
|
370 |
||
371 |
t1 := Timestamp now. |
|
372 |
t2 := t1 subtractMilliseconds:1. |
|
373 |
||
374 |
self assert:t2 < t1. |
|
375 |
self assert:t2 <= t1. |
|
376 |
self assert:(t2 = t1) not. |
|
377 |
self assert:(t2 >= t1) not. |
|
378 |
self assert:(t2 > t1) not. |
|
379 |
||
380 |
t1 := Timestamp now. |
|
381 |
t2 := t1 + 1 milliseconds. |
|
382 |
self assert:t2 = (t1 addMilliseconds:1). |
|
383 |
||
384 |
t2 := t1 - 1 milliseconds. |
|
385 |
self assert:t2 = (t1 addMilliseconds:-1). |
|
386 |
self assert:t2 = (t1 subtractMilliseconds:1). |
|
387 |
||
388 |
t1 := Timestamp now. |
|
389 |
t2 := t1 + 1 microseconds. |
|
390 |
||
391 |
self assert:t2 > t1. |
|
392 |
self assert:t2 >= t1. |
|
393 |
self assert:(t2 = t1) not. |
|
394 |
self assert:(t2 <= t1) not. |
|
395 |
self assert:(t2 < t1) not. |
|
396 |
||
397 |
t1 := Timestamp now. |
|
398 |
t2 := t1 - 1 microseconds. |
|
399 |
||
400 |
self assert:t2 < t1. |
|
401 |
self assert:t2 <= t1. |
|
402 |
self assert:(t2 = t1) not. |
|
403 |
self assert:(t2 >= t1) not. |
|
404 |
self assert:(t2 > t1) not. |
|
405 |
||
406 |
t1 := Timestamp now. |
|
407 |
t2 := t1 + 1 microseconds. |
|
408 |
self assert:t2 = (t1 addMilliseconds:0.001). |
|
409 |
||
410 |
t2 := t1 - 1 microseconds. |
|
411 |
self assert:t2 = (t1 addMilliseconds:-0.001). |
|
412 |
self assert:t2 = (t1 subtractMilliseconds:0.001). |
|
413 |
||
414 |
" |
|
415 |
self new test_20_comparing |
|
416 |
" |
|
417 |
! ! |
|
418 |
||
419 |
!TimeAndDateTest methodsFor:'tests-reading'! |
|
420 |
||
1886 | 421 |
test_01a_ReadingTimes |
422 |
self assert:(Time readFrom:'0:00' ) = (Time hours:0 minutes:0 seconds:0). |
|
423 |
self assert:(Time readFrom:'2:00' ) = (Time hours:2 minutes:0 seconds:0). |
|
424 |
self assert:(Time readFrom:'12:00' ) = (Time hours:12 minutes:0 seconds:0). |
|
425 |
self assert:(Time readFrom:'14:00' ) = (Time hours:14 minutes:0 seconds:0). |
|
426 |
self assert:(Time readFrom:'23:00' ) = (Time hours:23 minutes:0 seconds:0). |
|
346 | 427 |
|
1886 | 428 |
self assert:(Time readFrom:'18:22:00') = (Time hours:18 minutes:22 seconds:0). |
429 |
self assert:(Time readFrom:'14:00:11') = (Time hours:14 minutes:0 seconds:11). |
|
430 |
self assert:(Time readFrom:'7:00:11' ) = (Time hours:7 minutes:0 seconds:11). |
|
431 |
self assert:(Time readFrom:'0:00:00' ) = (Time hours:0 minutes:0 seconds:0). |
|
432 |
self assert:(Time readFrom:'12:00:00') = (Time hours:12 minutes:0 seconds:0). |
|
433 |
self assert:(Time readFrom:'0:00:00' ) = (Time hours:0 minutes:0 seconds:0). |
|
434 |
||
435 |
self assert:(Time readFrom:'14' ) = (Time hours:14 minutes:0 seconds:0). |
|
436 |
||
437 |
self assert:(Time readFrom:'2 am' ) = (Time hours:2 minutes:0 seconds:0). |
|
438 |
self assert:(Time readFrom:'2 pm' ) = (Time hours:14 minutes:0 seconds:0). |
|
346 | 439 |
|
1886 | 440 |
self assert:(Time readFrom:'2:30 am' ) = (Time hours:2 minutes:30 seconds:0). |
441 |
self assert:(Time readFrom:'2:30 pm' ) = (Time hours:14 minutes:30 seconds:0). |
|
442 |
self assert:(Time readFrom:'12:05 pm') = (Time hours:12 minutes:5 seconds:0). |
|
443 |
self assert:(Time readFrom:'12:06 am') = (Time hours:0 minutes:6 seconds:0). |
|
444 |
||
445 |
self assert:(Time readFrom:'6:22:00 pm' ) = (Time hours:18 minutes:22 seconds:0). |
|
446 |
self assert:(Time readFrom:'2:00:11 pm' ) = (Time hours:14 minutes:0 seconds:11). |
|
447 |
self assert:(Time readFrom:'7:00:11 am' ) = (Time hours:7 minutes:0 seconds:11). |
|
448 |
self assert:(Time readFrom:'12:00:00 am') = (Time hours:0 minutes:0 seconds:0). |
|
449 |
self assert:(Time readFrom:'0:00:00 am' ) = (Time hours:0 minutes:0 seconds:0). |
|
450 |
self assert:(Time readFrom:'12:00:00 pm') = (Time hours:12 minutes:0 seconds:0). |
|
451 |
self assert:(Time readFrom:'0:00:00 pm' onError:'invalid') = 'invalid'. |
|
452 |
||
453 |
self assert:(Time readFrom:'24:00' ) = (Time hours:0 minutes:0 seconds:0). |
|
454 |
self assert:(Time readFrom:'24:00:00') = (Time hours:0 minutes:0 seconds:0). |
|
455 |
||
456 |
self should:[Time readFrom:'24:00:00 am' ] raise:TimeConversionError. |
|
457 |
self should:[Time readFrom:'24:00:00 pm' ] raise:TimeConversionError. |
|
346 | 458 |
|
459 |
" |
|
1886 | 460 |
self new test_01a_ReadingTimes |
461 |
" |
|
462 |
||
463 |
"Created: / 09-11-2017 / 10:17:37 / cg" |
|
464 |
! |
|
465 |
||
466 |
test_01b_ReadingTimeDurations |
|
467 |
self assert:(TimeDuration readFrom:'0:00' ) = (TimeDuration hours:0 minutes:0 seconds:0). |
|
468 |
self assert:(TimeDuration readFrom:'2:00' ) = (TimeDuration hours:2 minutes:0 seconds:0). |
|
469 |
self assert:(TimeDuration readFrom:'12:00' ) = (TimeDuration hours:12 minutes:0 seconds:0). |
|
470 |
self assert:(TimeDuration readFrom:'14:00' ) = (TimeDuration hours:14 minutes:0 seconds:0). |
|
471 |
self assert:(TimeDuration readFrom:'23:00' ) = (TimeDuration hours:23 minutes:0 seconds:0). |
|
472 |
||
473 |
self assert:(TimeDuration readFrom:'18:22:00') = (TimeDuration hours:18 minutes:22 seconds:0). |
|
474 |
self assert:(TimeDuration readFrom:'14:00:11') = (TimeDuration hours:14 minutes:0 seconds:11). |
|
475 |
self assert:(TimeDuration readFrom:'7:00:11' ) = (TimeDuration hours:7 minutes:0 seconds:11). |
|
476 |
self assert:(TimeDuration readFrom:'0:00:00' ) = (TimeDuration hours:0 minutes:0 seconds:0). |
|
477 |
self assert:(TimeDuration readFrom:'12:00:00') = (TimeDuration hours:12 minutes:0 seconds:0). |
|
478 |
self assert:(TimeDuration readFrom:'0:00:00' ) = (TimeDuration hours:0 minutes:0 seconds:0). |
|
479 |
||
480 |
self assert:(TimeDuration readFrom:'14' ) = (TimeDuration hours:0 minutes:0 seconds:14). |
|
481 |
||
482 |
" |
|
483 |
self new test_01b_ReadingTimeDurations |
|
346 | 484 |
" |
1652 | 485 |
|
1886 | 486 |
"Created: / 09-11-2017 / 10:16:58 / cg" |
487 |
! |
|
488 |
||
489 |
test_01c_ReadingTimeStamps |
|
1924 | 490 |
|t| |
491 |
||
1886 | 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). |
493 |
||
494 |
"/ standard format |
|
495 |
self assert:(Timestamp readFrom:'2017-11-09') = (Timestamp year:2017 month:11 day:9 hour:0 minute:0 second:0). |
|
496 |
||
497 |
"/ US format |
|
498 |
self assert:(Timestamp readFrom:'12/09/2017') = (Timestamp year:2017 month:12 day:9 hour:0 minute:0 second:0). |
|
499 |
||
500 |
"/ european format |
|
501 |
self assert:(Timestamp readFrom:'9.11.2017') = (Timestamp year:2017 month:11 day:9 hour:0 minute:0 second:0). |
|
502 |
||
503 |
"/ explicit format |
|
504 |
self assert:(Timestamp readFrom:'9-nov-2017') = (Timestamp year:2017 month:11 day:9 hour:0 minute:0 second:0). |
|
505 |
"/ explicit format |
|
506 |
self assert:(Timestamp readFrom:'9. nov 2017') = (Timestamp year:2017 month:11 day:9 hour:0 minute:0 second:0). |
|
507 |
"/ explicit format |
|
508 |
self assert:(Timestamp readFrom:'9 nov 2017') = (Timestamp year:2017 month:11 day:9 hour:0 minute:0 second:0). |
|
509 |
||
1924 | 510 |
"/ milliseconds |
511 |
t := Timestamp readFrom:'2017-11-09 10:18:03.123'. |
|
512 |
self assert:(t milliseconds = 123). |
|
513 |
||
514 |
"/ microseconds |
|
515 |
t := Timestamp readFrom:'2017-11-09 10:18:03.123456'. |
|
516 |
self assert:(t microseconds = 123456). |
|
517 |
||
518 |
"/ nanoseconds |
|
519 |
t := Timestamp readFrom:'2017-11-09 10:18:03.123456789'. |
|
520 |
self assert:(t nanoseconds = 123456789). |
|
521 |
||
522 |
"/ picoseconds |
|
523 |
t := Timestamp readFrom:'2017-11-09 10:18:03.123456789012'. |
|
524 |
self assert:(t picoseconds = 123456789012). |
|
525 |
||
526 |
self assert:(t := Timestamp readFrom:'20-2-1995 13:11:06' format:'%day-%month-%year %h:%m:%s' language:nil onError:[self error] |
|
527 |
) = (Timestamp year:1995 month:2 day:20 hour:13 minute:11 second:6 millisecond:0). |
|
528 |
self assert:(t := Timestamp readFrom:'20021995131106' format:'%2d%2month%4y%2h%2m%2s' language:nil onError:[self error] |
|
529 |
) = (Timestamp year:1995 month:2 day:20 hour:13 minute:11 second:6 millisecond:0). |
|
530 |
self assert:(t := Timestamp readFrom:'200295131106' format:'%2d%2month%2y%2h%2m%2s' language:nil onError:[self error] |
|
531 |
) = (Timestamp year:95 month:2 day:20 hour:13 minute:11 second:6 millisecond:0). |
|
532 |
self assert:(t := Timestamp readFrom:'200260131106' format:'%2d%2month%2(y1900)%2h%2m%2s' language:nil onError:[self error] |
|
533 |
) = (Timestamp year:1960 month:2 day:20 hour:13 minute:11 second:6 millisecond:0). |
|
534 |
self assert:(t := Timestamp readFrom:'200260131106' format:'%2d%2month%2(y2000)%2h%2m%2s' language:nil onError:[self error] |
|
535 |
) = (Timestamp year:2060 month:2 day:20 hour:13 minute:11 second:6 millisecond:0). |
|
536 |
self assert:(t := Timestamp readFrom:'200260131106' format:'%2d%2month%2(y1950)%2h%2m%2s' language:nil onError:[self error] |
|
537 |
) = (Timestamp year:1960 month:2 day:20 hour:13 minute:11 second:6 millisecond:0). |
|
538 |
self assert:(t := Timestamp readFrom:'200260131106' format:'%2d%2month%2(y1980)%2h%2m%2s' language:nil onError:[self error] |
|
539 |
) = (Timestamp year:2060 month:2 day:20 hour:13 minute:11 second:6 millisecond:0). |
|
540 |
self assert:(t := Timestamp readFrom:'March 7 2009 2:30pm ' format:'%monthName %day %year %u:%m%a' language:#en onError:[self error] |
|
541 |
) = (Timestamp year:2009 month:3 day:7 hour:14 minute:30 second:0 millisecond:0). "/ EST is 5hrs behind |
|
542 |
self assert:(t := Timestamp readFrom:'March 7 2009 2:30am ' format:'%monthName %day %year %u:%m%a' language:#en onError:[self error] |
|
543 |
) = (Timestamp year:2009 month:3 day:7 hour:2 minute:30 second:0 millisecond:0). "/ EST is 5hrs behind |
|
544 |
||
1927 | 545 |
"/ Timestamp readIso8601FormatFrom:'20090307T183000-05' |
546 |
"/ Timestamp readIso8601FormatFrom:'20090307T233000Z' |
|
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] |
|
548 |
) = (UtcTimestamp year:2009 month:3 day:7 hour:23 minute:30 second:0 millisecond:0). "/ EST is 5hrs behind |
|
1924 | 549 |
|
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 | 551 |
) = (UtcTimestamp year:2009 month:3 day:7 hour:19 minute:30 second:0 millisecond:0). |
1924 | 552 |
|
553 |
self assert:(t := Timestamp readFrom:'2015103' format:'%4y%3dayOfYear' onError:[self error] |
|
1927 | 554 |
) = (Timestamp year:2015 month:4 day:13 hour:0 minute:0 second:0 millisecond:0). |
555 |
self assert:t asDate dayOfYear == 103. |
|
1924 | 556 |
|
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] |
|
558 |
) = (Timestamp year:1995 month:2 day:20 hour:13 minute:11 second:6 millisecond:999). |
|
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] |
|
560 |
) = (Timestamp year:1995 month:2 day:20 hour:13 minute:11 second:6 millisecond:100). |
|
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 | 562 |
) = (Timestamp year:1995 month:2 day:20 hour:13 minute:11 second:6 millisecond:10). |
1924 | 563 |
|
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] |
|
565 |
) = (Timestamp year:1995 month:2 day:20 hour:13 minute:11 second:6 millisecond:100). |
|
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] |
|
567 |
) = (Timestamp year:1995 month:2 day:20 hour:13 minute:11 second:6 millisecond:10). |
|
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] |
|
569 |
) = (Timestamp year:1995 month:2 day:20 hour:13 minute:11 second:6 millisecond:1). |
|
1927 | 570 |
|
1924 | 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 | 572 |
) = (Timestamp year:1995 month:2 day:20 hour:13 minute:11 second:6 microsecond:123000). |
573 |
||
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 | 575 |
) = (Timestamp year:1995 month:2 day:20 hour:13 minute:11 second:6 microsecond:123450). |
576 |
||
1927 | 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] |
578 |
) = ((Timestamp year:1995 month:2 day:20 hour:13 minute:11 second:6)+123456780 nanoseconds). |
|
579 |
||
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] |
|
581 |
) = ((Timestamp year:1995 month:2 day:20 hour:13 minute:11 second:6)+123456 microseconds). |
|
582 |
||
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] |
|
584 |
) = ((Timestamp year:1995 month:2 day:20 hour:13 minute:11 second:6)+123456789 nanoseconds). |
|
585 |
||
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] |
|
587 |
) = ((Timestamp year:1995 month:2 day:20 hour:13 minute:11 second:6)+123456789012 picoseconds). |
|
588 |
||
1886 | 589 |
" |
590 |
self new test_01c_ReadingTimeStamps |
|
591 |
" |
|
592 |
||
593 |
"Created: / 09-11-2017 / 10:19:19 / cg" |
|
1992 | 594 |
"Modified: / 27-07-2018 / 09:07:58 / Stefan Vogel" |
365 | 595 |
! |
596 |
||
1940 | 597 |
test_01d_ReadingTimeStamps |
598 |
|t| |
|
599 |
||
600 |
self assert:(t := Timestamp readFrom:'2017-11-09 10:18:03.236') printStringIso8601Format = '2017-11-09T10:18:03.236'. |
|
601 |
self assert:(t isLocalTimestamp). |
|
602 |
self assert:(t isUtcTimestamp not). |
|
603 |
self assert:(t isTZTimestamp not). |
|
604 |
||
605 |
self assert:(t := Timestamp readFrom:'2017-11-09 10:18:03.236Z') printStringIso8601Format = '2017-11-09T10:18:03.236Z'. |
|
606 |
self assert:(t isLocalTimestamp not). |
|
607 |
self assert:(t isUtcTimestamp). |
|
608 |
self assert:(t isTZTimestamp not). |
|
609 |
||
610 |
self should:[ Timestamp readFrom:'2017-11-09 10:18:03.236+1'] raise:Error. |
|
611 |
self should:[ Timestamp readIso8601FormatFrom:'2017-11-09 10:18:03.236+1'] raise:TimeConversionError. |
|
612 |
||
613 |
self assert:(t := Timestamp readFrom:'2017-11-09 10:18:03.236+01') printStringIso8601Format = '2017-11-09T10:18:03.236+01'. |
|
614 |
self assert:(t isLocalTimestamp not). |
|
615 |
self assert:(t isUtcTimestamp not). |
|
616 |
self assert:(t isTZTimestamp). |
|
617 |
||
618 |
" |
|
619 |
self new test_01d_ReadingTimeStamps |
|
620 |
" |
|
621 |
||
622 |
"Created: / 24-05-2018 / 17:45:08 / Claus Gittinger" |
|
623 |
! |
|
624 |
||
2391 | 625 |
test_01e_ReadingTimeStamps |
626 |
|t| |
|
627 |
||
628 |
self assert:(t := Timestamp readFrom:'1995-10-20T12:10:00.000') printStringIso8601Format = '1995-10-20T12:10:00'. |
|
629 |
self assert:(t isLocalTimestamp). |
|
630 |
self assert:(t isUtcTimestamp not). |
|
631 |
self assert:(t isTZTimestamp not). |
|
632 |
||
633 |
self assert:(t := Timestamp readFrom:'1995-10-20T12:10:00.010') printStringIso8601Format = '1995-10-20T12:10:00.010'. |
|
634 |
self assert:(t isLocalTimestamp). |
|
635 |
self assert:(t isUtcTimestamp not). |
|
636 |
self assert:(t isTZTimestamp not). |
|
637 |
||
638 |
self assert:(t := Timestamp readFrom:'2018-03-30T03:24:00') printStringIso8601Format = '2018-03-30T03:24:00'. |
|
639 |
self assert:(t isLocalTimestamp). |
|
640 |
self assert:(t isUtcTimestamp not). |
|
641 |
self assert:(t isTZTimestamp not). |
|
642 |
||
643 |
self assert:(t := Timestamp readFrom:'2018-3-30T03:24:00') printStringIso8601Format = '2018-03-30T03:24:00'. |
|
644 |
self assert:(t isLocalTimestamp). |
|
645 |
self assert:(t isUtcTimestamp not). |
|
646 |
self assert:(t isTZTimestamp not). |
|
647 |
||
648 |
" |
|
649 |
self new test_01e_ReadingTimeStamps |
|
650 |
" |
|
651 |
||
652 |
"Created: / 24-05-2018 / 17:45:08 / Claus Gittinger" |
|
653 |
! |
|
654 |
||
365 | 655 |
test_02_ReadingDates |
656 |
||
1447 | 657 |
self assert:(Date |
658 |
readFrom:'2-may-2010' |
|
659 |
printFormat:'%d-%shortMonthName-%y' |
|
660 |
language:'en' |
|
661 |
onError:[self error] |
|
662 |
) = (Date newDay:2 month:5 year:2010). |
|
365 | 663 |
|
736 | 664 |
{ |
1447 | 665 |
{ '3-jan-2012' . (Date newDay:3 month:1 year:2012) } . |
666 |
{ '15-feb-2012' . (Date newDay:15 month:2 year:2012) } . |
|
667 |
{ '06-mar-2011' . (Date newDay:6 month:3 year:2011) } . |
|
668 |
{ '19-apr-2013' . (Date newDay:19 month:4 year:2013) } . |
|
669 |
{ '21-may-2015' . (Date newDay:21 month:5 year:2015) } . |
|
670 |
{ '21-jun-2015' . (Date newDay:21 month:6 year:2015) } . |
|
671 |
{ '21-jul-2015' . (Date newDay:21 month:7 year:2015) } . |
|
672 |
{ '21-aug-2015' . (Date newDay:21 month:8 year:2015) } . |
|
673 |
{ '21-sep-2015' . (Date newDay:21 month:9 year:2015) } . |
|
674 |
{ '21-oct-2015' . (Date newDay:21 month:10 year:2015) } . |
|
675 |
{ '21-nov-2015' . (Date newDay:21 month:11 year:2015) } . |
|
676 |
{ '21-dec-2015' . (Date newDay:21 month:12 year:2015) } . |
|
736 | 677 |
} do:[:eachTestPair | |
1447 | 678 |
self assert:(Date |
679 |
readFrom:(eachTestPair first) |
|
680 |
printFormat:'%d-%shortMonthName-%y' |
|
681 |
language:'en' |
|
682 |
onError:[self error] |
|
683 |
) = (eachTestPair second). |
|
736 | 684 |
]. |
685 |
||
1447 | 686 |
self assert:(Date |
687 |
readFrom:'2-may-2010' |
|
688 |
printFormat:'%d-%monthName-%y' |
|
689 |
language:'en' |
|
690 |
onError:[self error] |
|
691 |
) = (Date newDay:2 month:5 year:2010). |
|
365 | 692 |
|
1447 | 693 |
self assert:(Date |
694 |
readFrom:'2-may-2010' |
|
695 |
printFormat:'%d-%(shortMonthName)-%y' |
|
696 |
language:'en' |
|
697 |
onError:[self error] |
|
698 |
) = (Date newDay:2 month:5 year:2010). |
|
366 | 699 |
|
1447 | 700 |
self assert:(Date |
701 |
readFrom:'2-may-2010' |
|
702 |
printFormat:'%d-%(monthName)-%y' |
|
703 |
language:'en' |
|
704 |
onError:[self error] |
|
705 |
) = (Date newDay:2 month:5 year:2010). |
|
366 | 706 |
|
1447 | 707 |
self assert:(Date |
708 |
readFrom:'2-5-2010' |
|
709 |
printFormat:'%d-%m-%y' |
|
710 |
onError:[self error] |
|
711 |
) = (Date newDay:2 month:5 year:2010). |
|
365 | 712 |
|
1447 | 713 |
self assert:(Date |
714 |
readFrom:'5/2/2010' |
|
715 |
printFormat:'%m/%d/%y' |
|
716 |
onError:[self error] |
|
717 |
) = (Date newDay:2 month:5 year:2010). |
|
365 | 718 |
|
1447 | 719 |
self assert:(Date |
720 |
readFrom:'2010-5-2' |
|
721 |
printFormat:'%y-%m-%d' |
|
722 |
onError:[self error] |
|
723 |
) = (Date newDay:2 month:5 year:2010). |
|
365 | 724 |
|
725 |
" |
|
726 |
self new test_02_ReadingDates |
|
727 |
" |
|
736 | 728 |
! |
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 | 732 |
{ '2004-W53-6' . 'sat' . (Date newDay:1 month:1 year:2005) } . |
733 |
{ '2004-W53-7' . 'sun' . (Date newDay:2 month:1 year:2005) } . |
|
734 |
{ '2005-W52-6' . 'sat' . (Date newDay:31 month:12 year:2005) } . |
|
735 |
{ '2007-W01-1' . 'mon' . (Date newDay:1 month:1 year:2007) } . |
|
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 | 738 |
{ '2008-W01-1' . 'mon' . (Date newDay:31 month:12 year:2007) } . |
739 |
{ '2008-W01-2' . 'tue' . (Date newDay:1 month:1 year:2008) } . |
|
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 | 742 |
{ '2009-W01-1' . 'mon' . (Date newDay:29 month:12 year:2008) } . |
743 |
{ '2009-W01-2' . 'tue' . (Date newDay:30 month:12 year:2008) } . |
|
744 |
{ '2009-W01-3' . 'wed' . (Date newDay:31 month:12 year:2008) } . |
|
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 | 747 |
{ '2009-W53-4' . 'thu' . (Date newDay:31 month:12 year:2009) } . |
748 |
{ '2009-W53-5' . 'fri' . (Date newDay:1 month:1 year:2010) } . |
|
749 |
{ '2009-W53-6' . 'sat' . (Date newDay:2 month:1 year:2010) } . |
|
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 | 752 |
|input expected expectedDayName got gotName| |
1217
ee9044742185
class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents:
1077
diff
changeset
|
753 |
|
1447 | 754 |
input := eachTriple first. |
755 |
expectedDayName := eachTriple second. |
|
756 |
expected := eachTriple third. |
|
757 |
got := (Timestamp readIso8601FormatFrom:input onError:nil) asDate. |
|
758 |
self assert:(got = expected) description:'wrong: ',input. |
|
759 |
gotName := got abbreviatedDayNameForLanguage:#en. |
|
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 | 775 |
{ '1995-02-20T13:11:06.123' . '1995-02-20 13:11:06.123' } . |
776 |
{ '1995-02-20T13:11:06' . '1995-02-20 13:11:06' } . |
|
777 |
{ '1995-02T13:11:06' . '1995-02-01 13:11:06' } . |
|
778 |
{ '1995T13:11:06' . '1995-01-01 13:11:06' } . |
|
779 |
{ '1995T13:11' . '1995-01-01 13:11:00' } . |
|
780 |
{ '1995T13:11.5' . '1995-01-01 13:11:30' } . |
|
781 |
{ '1995T13:11,5' . '1995-01-01 13:11:30' } . |
|
782 |
{ '1995T13' . '1995-01-01 13:00:00' } . |
|
783 |
{ '1995T13.25' . '1995-01-01 13:15:00' } . |
|
784 |
{ '1995T13.333333' . '1995-01-01 13:19:59.999' } . |
|
785 |
{ '1995' . '1995-01-01 00:00:00' } . |
|
786 |
{ '1995-02' . '1995-02-01 00:00:00' } . |
|
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 | 790 |
{ '1995-001' . '1995-01-01 00:00:00' } . |
791 |
{ '1995-035' . '1995-02-04 00:00:00' } . |
|
792 |
{ '1995035' . '1995-02-04 00:00:00' } . |
|
1219
369f5bac6379
class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents:
1218
diff
changeset
|
793 |
|
1447 | 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 | 796 |
{ '1997-W01' . '1996-12-30 00:00:00' } . |
797 |
{ '1997W01' . '1996-12-30 00:00:00' } . |
|
798 |
{ '1997W01-1' . '1996-12-30 00:00:00' } . |
|
799 |
{ '1997W011' . '1996-12-30 00:00:00' } . |
|
800 |
{ '1997W01' . '1996-12-30 00:00:00' } . |
|
801 |
{ '1997W01-2' . '1996-12-31 00:00:00' } . |
|
802 |
{ '1997-W01-2' . '1996-12-31 00:00:00' } . |
|
803 |
{ '1997W012' . '1996-12-31 00:00:00' } . |
|
804 |
{ '2014W40' . '2014-09-29 00:00:00' } . |
|
805 |
{ '2014W44-4' . '2014-10-30 00:00:00' } . |
|
806 |
{ '2014W01' . '2013-12-30 00:00:00' } . |
|
807 |
{ '2014W01-1' . '2013-12-30 00:00:00' } . |
|
808 |
{ '2014W01-2' . '2013-12-31 00:00:00' } . |
|
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 | 811 |
{ '1995-02-20 13:11' . '1995-02-20 13:11:00' } . |
812 |
{ '1995-02-20 1311' . '1995-02-20 13:11:00' } . |
|
813 |
{ '1995-02-20 13' . '1995-02-20 13:00:00' } . |
|
814 |
{ '1995-02-20 235959' . '1995-02-20 23:59:59' } . |
|
815 |
{ '19950220 235959' . '1995-02-20 23:59:59' } . |
|
816 |
{ '19950220 23:59:59.9942' . '1995-02-20 23:59:59.994' } . |
|
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 | 820 |
{ '1995-02-20 13:11:06' . '1995-02-20 13:11:06' } . |
821 |
{ '1995-02-20 13:11:06Z' . '1995-02-20 13:11:06Z' } . |
|
822 |
{ '1995-02-20 13:11:06+01' . '1995-02-20 13:11:06+01' } . |
|
823 |
{ '1995-02-20 13:11:06+01:00' . '1995-02-20 13:11:06+01' } . |
|
824 |
{ '1995-02-20 13:11:06+01:30' . '1995-02-20 13:11:06+01:30' } . |
|
825 |
{ '1995-02-20 13:11:06+0130' . '1995-02-20 13:11:06+01:30' } . |
|
826 |
{ '1995-02-20 13:11:06-01' . '1995-02-20 13:11:06-01' } . |
|
827 |
{ '1995-02-20 13:11:06-01:00' . '1995-02-20 13:11:06-01' } . |
|
828 |
{ '1995-02-20 13:11:06-01:30' . '1995-02-20 13:11:06-01:30' } . |
|
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 | 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 | 834 |
|s1 t expected got| |
1219
369f5bac6379
class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents:
1218
diff
changeset
|
835 |
|
1447 | 836 |
s1 := eachPair first. |
837 |
t := Timestamp readIso8601FormatFrom:s1. |
|
838 |
expected := eachPair second. |
|
839 |
got := t asString. |
|
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 | 852 |
{ '1995-02-20T13:11:06.123' . '1995-02-20 13:11:06.123Z' } . |
853 |
{ '1995-02-20T13:11:06' . '1995-02-20 13:11:06Z' } . |
|
854 |
{ '1995-02T13:11:06' . '1995-02-01 13:11:06Z' } . |
|
855 |
{ '1995T13:11:06' . '1995-01-01 13:11:06Z' } . |
|
856 |
{ '1995T13:11' . '1995-01-01 13:11:00Z' } . |
|
857 |
{ '1995T13:11.5' . '1995-01-01 13:11:30Z' } . |
|
858 |
{ '1995T13:11,5' . '1995-01-01 13:11:30Z' } . |
|
859 |
{ '1995T13' . '1995-01-01 13:00:00Z' } . |
|
860 |
{ '1995T13.25' . '1995-01-01 13:15:00Z' } . |
|
861 |
{ '1995T13.333333' . '1995-01-01 13:19:59.999Z' } . |
|
862 |
{ '1995' . '1995-01-01 00:00:00Z' } . |
|
863 |
{ '1995-02' . '1995-02-01 00:00:00Z' } . |
|
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 | 867 |
{ '1995-001' . '1995-01-01 00:00:00Z' } . |
868 |
{ '1995-035' . '1995-02-04 00:00:00Z' } . |
|
869 |
{ '1995035' . '1995-02-04 00:00:00Z' } . |
|
1226
b5123dd5c3da
class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents:
1225
diff
changeset
|
870 |
|
1447 | 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 | 873 |
{ '1997-W01' . '1996-12-30 00:00:00Z' } . |
874 |
{ '1997W01' . '1996-12-30 00:00:00Z' } . |
|
875 |
{ '1997W01-1' . '1996-12-30 00:00:00Z' } . |
|
876 |
{ '1997W011' . '1996-12-30 00:00:00Z' } . |
|
877 |
{ '1997W01' . '1996-12-30 00:00:00Z' } . |
|
878 |
{ '1997W01-2' . '1996-12-31 00:00:00Z' } . |
|
879 |
{ '1997-W01-2' . '1996-12-31 00:00:00Z' } . |
|
880 |
{ '1997W012' . '1996-12-31 00:00:00Z' } . |
|
881 |
{ '2014W40' . '2014-09-29 00:00:00Z' } . |
|
882 |
{ '2014W44-4' . '2014-10-30 00:00:00Z' } . |
|
883 |
{ '2014W01' . '2013-12-30 00:00:00Z' } . |
|
884 |
{ '2014W01-1' . '2013-12-30 00:00:00Z' } . |
|
885 |
{ '2014W01-2' . '2013-12-31 00:00:00Z' } . |
|
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 | 888 |
{ '1995-02-20 13:11' . '1995-02-20 13:11:00Z' } . |
889 |
{ '1995-02-20 1311' . '1995-02-20 13:11:00Z' } . |
|
890 |
{ '1995-02-20 13' . '1995-02-20 13:00:00Z' } . |
|
891 |
{ '1995-02-20 235959' . '1995-02-20 23:59:59Z' } . |
|
892 |
{ '19950220 235959' . '1995-02-20 23:59:59Z' } . |
|
893 |
{ '19950220 23:59:59.9942' . '1995-02-20 23:59:59.994Z' } . |
|
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 | 897 |
{ '1995-02-20 13:11:06' . '1995-02-20 13:11:06Z' } . |
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 | 900 |
{ '1995-02-20 13:11:06+01:00' . '1995-02-20 12:11:06Z' } . "/ notice the changed time here!!!!!! |
901 |
{ '1995-02-20 13:11:06+01:30' . '1995-02-20 11:41:06Z' } . "/ notice the changed time here!!!!!! |
|
902 |
{ '1995-02-20 13:11:06+0130' . '1995-02-20 11:41:06Z' } . "/ notice the changed time here!!!!!! |
|
903 |
{ '1995-02-20 13:11:06-01' . '1995-02-20 14:11:06Z' } . |
|
904 |
{ '1995-02-20 13:11:06-01:00' . '1995-02-20 14:11:06Z' } . |
|
905 |
{ '1995-02-20 13:11:06-01:30' . '1995-02-20 14:41:06Z' } . |
|
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 | 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 | 911 |
|s1 t expected got| |
1226
b5123dd5c3da
class: RegressionTests::TimeAndDateTest
Claus Gittinger <cg@exept.de>
parents:
1225
diff
changeset
|
912 |
|
1447 | 913 |
s1 := eachPair first. |
914 |
t := UtcTimestamp readIso8601FormatFrom:s1. |
|
915 |
expected := eachPair second. |
|
916 |
got := t asString. |
|
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 | 933 |
year: 2005 month: 6 day: 15 |
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 | 1007 |
self assert: ts = (reader read: '2005-06-15T17:37:00.030' withClass:UtcTimestamp). |
1008 |
||
1009 |
ts := UtcTimestamp year: 2005 month: 6 day: 15 hour: 17 minute: 37 second: 0 microsecond:300. |
|
1010 |
self assert: ts = (reader read: '05-0615T17:3700.0003' withClass:UtcTimestamp). |
|
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 | 1026 |
year: 2005 month: 6 day: 15 |
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 | 1066 |
! |
1067 |
||
1068 |
test_17_readingBrokenStrings |
|
1069 |
"endless loop happened with: |
|
1070 |
Timestamp readFrom:'0' onError:#foo |
|
1071 |
" |
|
1072 |
||
1073 |
#( |
|
1074 |
'' |
|
1075 |
'0' |
|
1076 |
'1' |
|
1077 |
'1-' |
|
1078 |
'1-1' |
|
1079 |
'1-1-' |
|
1080 |
'1-1-1 10' |
|
1081 |
'0-0-0' |
|
1082 |
) do:[:eachBadString | |
|
1083 |
| ts | |
|
1084 |
||
1085 |
"/ should not run into an endless loop |
|
1086 |
[ |
|
1087 |
ts := Timestamp readFrom:eachBadString onError:#foo. |
|
1088 |
] valueWithTimeout:(50 milliseconds). |
|
1089 |
||
1090 |
self assert: (ts notNil) description:'timestamp reading leads to endless loop'. |
|
1091 |
self assert: ts == #foo. |
|
1092 |
]. |
|
1093 |
||
1094 |
" |
|
1095 |
self new test_17_readingBrokenStrings |
|
1096 |
" |
|
1097 |
||
1098 |
"Created: / 09-11-2017 / 10:00:30 / cg" |
|
1924 | 1099 |
! |
1100 |
||
2330 | 1101 |
test_21_readingDateInVariousFormats |
1102 |
{ |
|
1103 |
'1.1.1990' . '%d %m %y' . (Date year:1990 month:1 day:1 ) . |
|
1104 |
'1.1.2090' . '%d %m %y' . (Date year:2090 month:1 day:1 ) . |
|
1105 |
||
1106 |
'1.1.49' . '%d %m %(Y1950)' . (Date year:2049 month:1 day:1 ) . |
|
1107 |
'1.1.50' . '%d %m %(Y1950)' . (Date year:1950 month:1 day:1 ) . |
|
1108 |
'1.1.51' . '%d %m %(Y1950)' . (Date year:1951 month:1 day:1 ) . |
|
1109 |
'1.1.99' . '%d %m %(Y1950)' . (Date year:1999 month:1 day:1 ) . |
|
1924 | 1110 |
|
2330 | 1111 |
'1.1.69' . '%d %m %(Y1970)' . (Date year:2069 month:1 day:1 ) . |
1112 |
'1.1.70' . '%d %m %(Y1970)' . (Date year:1970 month:1 day:1 ) . |
|
1113 |
'1.1.71' . '%d %m %(Y1970)' . (Date year:1971 month:1 day:1 ) . |
|
1114 |
'1.1.99' . '%d %m %(Y1970)' . (Date year:1999 month:1 day:1 ) . |
|
1924 | 1115 |
|
2330 | 1116 |
'1.1.79' . '%d %m %(Y1980)' . (Date year:2079 month:1 day:1 ) . |
1117 |
'1.1.80' . '%d %m %(Y1980)' . (Date year:1980 month:1 day:1 ) . |
|
1118 |
'1.1.81' . '%d %m %(Y1980)' . (Date year:1981 month:1 day:1 ) . |
|
1119 |
'1.1.99' . '%d %m %(Y1980)' . (Date year:1999 month:1 day:1 ) . |
|
1924 | 1120 |
|
2330 | 1121 |
'1.1.49' . '%d %m %(Y1900)' . (Date year:1949 month:1 day:1 ) . |
1122 |
'1.1.69' . '%d %m %(Y1900)' . (Date year:1969 month:1 day:1 ) . |
|
1123 |
'1.1.79' . '%d %m %(Y1900)' . (Date year:1979 month:1 day:1 ) . |
|
1124 |
'1.1.80' . '%d %m %(Y1900)' . (Date year:1980 month:1 day:1 ) . |
|
1125 |
'1.1.81' . '%d %m %(Y1900)' . (Date year:1981 month:1 day:1 ) . |
|
1126 |
'1.1.99' . '%d %m %(Y1900)' . (Date year:1999 month:1 day:1 ) . |
|
1924 | 1127 |
|
2330 | 1128 |
'1.1.49' . '%d %m %(Y2000)' . (Date year:2049 month:1 day:1 ) . |
1129 |
'1.1.69' . '%d %m %(Y2000)' . (Date year:2069 month:1 day:1 ) . |
|
1130 |
'1.1.79' . '%d %m %(Y2000)' . (Date year:2079 month:1 day:1 ) . |
|
1131 |
'1.1.80' . '%d %m %(Y2000)' . (Date year:2080 month:1 day:1 ) . |
|
1132 |
'1.1.81' . '%d %m %(Y2000)' . (Date year:2081 month:1 day:1 ) . |
|
1133 |
'1.1.99' . '%d %m %(Y2000)' . (Date year:2099 month:1 day:1 ) . |
|
1134 |
} inGroupsOf:3 do:[:str :fmt :expected | |
|
1135 |
| result | |
|
1924 | 1136 |
|
2330 | 1137 |
result := Date readFrom:str format:fmt onError:#foo. |
1138 |
||
1139 |
self assert: result = expected. |
|
1140 |
]. |
|
1141 |
||
1924 | 1142 |
" |
2330 | 1143 |
self new test_21_readingDateInVariousFormats |
1144 |
" |
|
1924 | 1145 |
|
2330 | 1146 |
"Created: / 09-11-2017 / 10:00:30 / cg" |
346 | 1147 |
! ! |
1148 |
||
1149 |
!TimeAndDateTest class methodsFor:'documentation'! |
|
1150 |
||
1151 |
version |
|
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 | 1157 |
! ! |
1077 | 1158 |