0
|
1 |
// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// e32test\y2k\t_y2k.cpp
|
|
15 |
// Overview:
|
|
16 |
// Year 2000 compliance tests for E32
|
|
17 |
// API Information:
|
|
18 |
// TTime, TDateTime, RTimer
|
|
19 |
// Details:
|
|
20 |
// - Test the T_Time & TDateTime classes in accordance with the test spec for Y2K
|
|
21 |
// Section 4.1.1.1. Set a variety of date and time values, calculate using different
|
|
22 |
// TTimeInterval methods, verify results are as expected.
|
|
23 |
// - Test the input of valid and invalid dates to TDateTime and TTime. Verify results.
|
|
24 |
// - Test operators <=, >=, >, <, +, - on TDateTime and TTime objects. Verify results.
|
|
25 |
// - Test days of the week, verify results are as expected.
|
|
26 |
// - Test various timer alarms, verify results are as expected.
|
|
27 |
// Platforms/Drives/Compatibility:
|
|
28 |
// All.
|
|
29 |
// Assumptions/Requirement/Pre-requisites:
|
|
30 |
// Failures and causes:
|
|
31 |
// Base Port information:
|
|
32 |
//
|
|
33 |
//
|
|
34 |
|
|
35 |
#include <e32test.h>
|
|
36 |
|
|
37 |
// Use this to test all the elements, and still give useful line numbers
|
|
38 |
#define dttest(q,x,y,z,a,b,c,d) test(q.Year()==x), test(q.Month()==(y)-1), \
|
|
39 |
test(q.Day()==(z)-1), test(q.Hour()==a), test(q.Minute()==b), test(q.Second()==c),\
|
|
40 |
test(q.MicroSecond()==d)
|
|
41 |
|
|
42 |
LOCAL_D RTest test(_L("T_Y2K"));
|
|
43 |
|
|
44 |
#define __TRACE_LINE test.Printf(_L("line %d\n"),__LINE__)
|
|
45 |
|
|
46 |
// test fields in TDateTime, using sensible dates (ie 1/1/1999 not 0/0/1999)
|
|
47 |
|
|
48 |
class TestY2K
|
|
49 |
{
|
|
50 |
public:
|
|
51 |
void Test1(); // test TTime for Y2K compliance
|
|
52 |
void Test2();
|
|
53 |
void Test3();
|
|
54 |
void Test4();
|
|
55 |
void Test5();
|
|
56 |
};
|
|
57 |
|
|
58 |
void PrintTime(const TDesC& aName, const TTime& aTime)
|
|
59 |
{
|
|
60 |
TDateTime dt(aTime.DateTime());
|
|
61 |
test.Printf(_L("%S = %02d:%02d:%02d:%06d\n"),&aName,dt.Hour(),dt.Minute(),dt.Second(),dt.MicroSecond());
|
|
62 |
}
|
|
63 |
|
|
64 |
void TestY2K::Test1()
|
|
65 |
{
|
|
66 |
// Test the T_Time & TDateTime classes in accordance with the test spec for Y2K
|
|
67 |
// Section 4.1.1.1
|
|
68 |
|
|
69 |
// 31/12/1998 and 1/1/1999
|
|
70 |
test.Next(_L("Testing existing functionality"));
|
|
71 |
TTime t1;
|
|
72 |
TTime t2;
|
|
73 |
TDateTime dt;
|
|
74 |
|
|
75 |
test(t1.Set(_L("19981130:235959.999999"))==KErrNone);
|
|
76 |
test(t2.Set(_L("19990000:000000."))==KErrNone);
|
|
77 |
|
|
78 |
dt=t1.DateTime();
|
|
79 |
|
|
80 |
test(dt.Year()==1998);
|
|
81 |
test(dt.Month()==EDecember);
|
|
82 |
test(dt.Day()==30);
|
|
83 |
|
|
84 |
t1+=TTimeIntervalMicroSeconds(1);
|
|
85 |
dt=t1.DateTime();
|
|
86 |
|
|
87 |
dttest(dt,1999,1,1,0,0,0,0);
|
|
88 |
test(t1==t2);
|
|
89 |
|
|
90 |
test(t1.Set(_L("19981130:235900.000000"))==KErrNone);
|
|
91 |
test(t2.Set(_L("19990000:000001.000000"))==KErrNone);
|
|
92 |
|
|
93 |
|
|
94 |
t1+=TTimeIntervalSeconds(61);
|
|
95 |
dt=t1.DateTime();
|
|
96 |
|
|
97 |
dttest(dt,1999,1,1,0,0,1,0);
|
|
98 |
test(t1==t2);
|
|
99 |
|
|
100 |
t1.Set(_L("19981130:234500.000100"));
|
|
101 |
t2.Set(_L("19990000:000100.000100"));
|
|
102 |
t1+=TTimeIntervalMinutes(16);
|
|
103 |
dt=t1.DateTime();
|
|
104 |
|
|
105 |
dttest(dt,1999,1,1,0,1,0,100);
|
|
106 |
test(t1==t2);
|
|
107 |
|
|
108 |
t1.Set(_L("19981130:230000.000001"));
|
|
109 |
t2.Set(_L("19990000:000000.000001"));
|
|
110 |
t1+=TTimeIntervalHours(1);
|
|
111 |
dt=t1.DateTime();
|
|
112 |
|
|
113 |
dttest(dt,1999,1,1,0,0,0,1);
|
|
114 |
test(t1==t2);
|
|
115 |
|
|
116 |
t1.Set(_L("19990000:164523.101000"));
|
|
117 |
t2.Set(_L("19981130:164523.101000"));
|
|
118 |
t1-=TTimeIntervalDays(1);
|
|
119 |
dt=t1.DateTime();
|
|
120 |
|
|
121 |
dttest(dt,1998,12,31,16,45,23,101000);
|
|
122 |
test(t1==t2);
|
|
123 |
|
|
124 |
t1.Set(_L("19990030:164523.999999"));
|
|
125 |
t2.Set(_L("19981130:164523.999999"));
|
|
126 |
t1-=TTimeIntervalMonths(1);
|
|
127 |
dt=t1.DateTime();
|
|
128 |
|
|
129 |
dttest(dt,1998,12,31,16,45,23,999999);
|
|
130 |
test(t1==t2);
|
|
131 |
|
|
132 |
t1.Set(_L("19990000:235959.999999"));
|
|
133 |
t2.Set(_L("19980000:235959.999999"));
|
|
134 |
t1-=TTimeIntervalYears(1);
|
|
135 |
dt=t1.DateTime();
|
|
136 |
|
|
137 |
dttest(dt,1998,1,1,23,59,59,999999);
|
|
138 |
test(t1==t2);
|
|
139 |
|
|
140 |
// Direct setting
|
|
141 |
t1.Set(_L("19981130:235959.999999"));
|
|
142 |
test(dt.SetYear(1998)==KErrNone);
|
|
143 |
test(dt.SetMonth(EDecember)==KErrNone);
|
|
144 |
test(dt.SetDay(30)==KErrNone);
|
|
145 |
test(dt.SetHour(23)==KErrNone);
|
|
146 |
test(dt.SetMinute(59)==KErrNone);
|
|
147 |
test(dt.SetSecond(59)==KErrNone);
|
|
148 |
test(dt.SetMicroSecond(999999)==KErrNone);
|
|
149 |
test(t1==dt);
|
|
150 |
|
|
151 |
t1.Set(_L("19990000:101010.101000"));
|
|
152 |
test(dt.SetYear(1999)==KErrNone);
|
|
153 |
test(dt.SetMonth(EJanuary)==KErrNone);
|
|
154 |
test(dt.SetDay(0)==KErrNone);
|
|
155 |
test(dt.SetHour(10)==KErrNone);
|
|
156 |
test(dt.SetMinute(10)==KErrNone);
|
|
157 |
test(dt.SetSecond(10)==KErrNone);
|
|
158 |
test(dt.SetMicroSecond(101000)==KErrNone);
|
|
159 |
test(t1==dt);
|
|
160 |
|
|
161 |
|
|
162 |
// 27/2/1998 & 28/2/1998
|
|
163 |
|
|
164 |
t1.Set(_L("19980126:144559.101000"));
|
|
165 |
t2.Set(_L("19980127:144559.101000"));
|
|
166 |
|
|
167 |
dt=t1.DateTime();
|
|
168 |
dttest(dt,1998,2,27,14,45,59,101000);
|
|
169 |
|
|
170 |
t1+=TTimeIntervalDays(1);
|
|
171 |
test(t1==t2);
|
|
172 |
dt=t2.DateTime();
|
|
173 |
|
|
174 |
dttest(dt,1998,2,28,14,45,59,101000);
|
|
175 |
|
|
176 |
// 28/2/1998 & 1/3/1998
|
|
177 |
|
|
178 |
t1.Set(_L("19980127:"));
|
|
179 |
t2.Set(_L("19980200:"));
|
|
180 |
dt=t1.DateTime();
|
|
181 |
|
|
182 |
dttest(dt,1998,2,28,0,0,0,0);
|
|
183 |
|
|
184 |
t1+=TTimeIntervalDays(1);
|
|
185 |
test(t1==t2);
|
|
186 |
dt=t2.DateTime();
|
|
187 |
|
|
188 |
dttest(dt,1998,3,1,0,0,0,0);
|
|
189 |
|
|
190 |
// 31/8/1999 & 1/9/1999
|
|
191 |
|
|
192 |
t1.Set(_L("19990730:235959.121200"));
|
|
193 |
t2.Set(_L("19990800:000000.121200"));
|
|
194 |
dt=t1.DateTime();
|
|
195 |
|
|
196 |
dttest(dt,1999,8,31,23,59,59,121200);
|
|
197 |
|
|
198 |
t1+=TTimeIntervalSeconds(1);
|
|
199 |
test(t1==t2);
|
|
200 |
dt=t2.DateTime();
|
|
201 |
|
|
202 |
dttest(dt,1999,9,1,0,0,0,121200);
|
|
203 |
|
|
204 |
// 8/9/1999 & 9/9/1999
|
|
205 |
|
|
206 |
t1.Set(_L("19990807:233434."));
|
|
207 |
t2.Set(_L("19990808:003434."));
|
|
208 |
dt=t1.DateTime();
|
|
209 |
|
|
210 |
dttest(dt,1999,9,8,23,34,34,0);
|
|
211 |
|
|
212 |
t1+=TTimeIntervalHours(1);
|
|
213 |
test(t1==t2);
|
|
214 |
dt=t2.DateTime();
|
|
215 |
|
|
216 |
dttest(dt,1999,9,9,0,34,34,0);
|
|
217 |
|
|
218 |
// 9/9/1999 & 10/9/1999
|
|
219 |
|
|
220 |
t1.Set(_L("19990808:235934."));
|
|
221 |
t2.Set(_L("19990809:000034."));
|
|
222 |
dt=t1.DateTime();
|
|
223 |
|
|
224 |
dttest(dt,1999,9,9,23,59,34,0);
|
|
225 |
|
|
226 |
t1+=TTimeIntervalMinutes(1);
|
|
227 |
test(t1==t2);
|
|
228 |
dt=t2.DateTime();
|
|
229 |
|
|
230 |
dttest(dt,1999,9,10,0,0,34,0);
|
|
231 |
|
|
232 |
// 31/12/1999 & 1/1/2000
|
|
233 |
|
|
234 |
test(t1.Set(_L("19991130:"))==KErrNone);
|
|
235 |
test(t2.Set(_L("20000000:"))==KErrNone);
|
|
236 |
dt=t1.DateTime();
|
|
237 |
|
|
238 |
dttest(dt,1999,12,31,0,0,0,0);
|
|
239 |
|
|
240 |
t1+=TTimeIntervalDays(1);
|
|
241 |
test(t1==t2);
|
|
242 |
dt=t2.DateTime();
|
|
243 |
|
|
244 |
dttest(dt,2000,1,1,0,0,0,0);
|
|
245 |
|
|
246 |
test(dt.SetYear(2000)==KErrNone);
|
|
247 |
test(dt.SetMonth(EJanuary)==KErrNone);
|
|
248 |
test(dt.SetDay(0)==KErrNone);
|
|
249 |
test(dt.SetHour(0)==KErrNone);
|
|
250 |
test(dt.SetMinute(0)==KErrNone);
|
|
251 |
test(dt.SetSecond(0)==KErrNone);
|
|
252 |
test(dt.SetMicroSecond(0)==KErrNone);
|
|
253 |
|
|
254 |
test(t1==dt);
|
|
255 |
test(t1.DayNoInYear()==1);
|
|
256 |
test(t1.WeekNoInYear(EFirstWeek)==1);
|
|
257 |
test(t2.DaysInMonth()==31);
|
|
258 |
|
|
259 |
// 27/2/2000 to 28/2/2000
|
|
260 |
|
|
261 |
test(t1.Set(_L("20000126:235958.999999"))==KErrNone);
|
|
262 |
test(t2.Set(_L("20000127:"))==KErrNone);
|
|
263 |
dt=t1.DateTime();
|
|
264 |
|
|
265 |
dttest(dt,2000,2,27,23,59,58,999999);
|
|
266 |
|
|
267 |
t1+=TTimeIntervalSeconds(1);
|
|
268 |
t1+=TTimeIntervalMicroSeconds(1);
|
|
269 |
test(t1==t2);
|
|
270 |
test(t1.DaysInMonth()==29);
|
|
271 |
dt=t2.DateTime();
|
|
272 |
|
|
273 |
dttest(dt,2000,2,28,0,0,0,0);
|
|
274 |
|
|
275 |
// 28/2/2000 & 29/2/2000
|
|
276 |
|
|
277 |
test(t2.Set(_L("20000128:"))==KErrNone);
|
|
278 |
test(dt.Set(2000,EFebruary,28,0,0,0,0)==KErrNone);
|
|
279 |
|
|
280 |
t1+=TTimeIntervalDays(1);
|
|
281 |
test(t1==t2);
|
|
282 |
test(t1==dt);
|
|
283 |
test(Time::IsLeapYear(t2.DateTime().Year()));
|
|
284 |
test(t1.DayNoInMonth()==28);
|
|
285 |
test(t1.DaysFrom(t2)==TTimeIntervalDays(0));
|
|
286 |
t2.Set(_L("20000200:"));
|
|
287 |
test(t1.DaysFrom(t2)==TTimeIntervalDays(-1));
|
|
288 |
test(t2.DaysFrom(t1)==TTimeIntervalDays(1));
|
|
289 |
|
|
290 |
// 29/2/2000 to 1/3/2000
|
|
291 |
|
|
292 |
t1.Set(_L("20000128:"));
|
|
293 |
t2.Set(_L("20000200:"));
|
|
294 |
|
|
295 |
dt=t1.DateTime();
|
|
296 |
dttest(dt,2000,2,29,0,0,0,0);
|
|
297 |
t1+=TTimeIntervalHours(24);
|
|
298 |
test(t1==t2);
|
|
299 |
dt=t1.DateTime();
|
|
300 |
dttest(dt,2000,3,1,0,0,0,0);
|
|
301 |
|
|
302 |
// 31/12/2000 & 1/1/2001
|
|
303 |
|
|
304 |
t1.Set(_L("20001130:"));
|
|
305 |
t2.Set(_L("20010000:235945."));
|
|
306 |
dt=t1.DateTime();
|
|
307 |
dttest(dt,2000,12,31,0,0,0,0);
|
|
308 |
test(t1!=t2);
|
|
309 |
t1+=TTimeIntervalHours(24);
|
|
310 |
t1+=TTimeIntervalMinutes(60*23);
|
|
311 |
t1+=TTimeIntervalSeconds(59*60+45);
|
|
312 |
test(t1==t2);
|
|
313 |
|
|
314 |
dt=t1.DateTime();
|
|
315 |
dttest(dt,2001,1,1,23,59,45,0);
|
|
316 |
|
|
317 |
// 28/2/2001 & 1/3/2001
|
|
318 |
test(t1.Set(_L("20010127:"))==KErrNone);
|
|
319 |
test(t2.Set(_L("20010200:"))==KErrNone);
|
|
320 |
test(t2.DaysFrom(t1)==TTimeIntervalDays(1));
|
|
321 |
test(t2.MonthsFrom(t1)==TTimeIntervalMonths(0));
|
|
322 |
dt=t1.DateTime();
|
|
323 |
dttest(dt,2001,2,28,0,0,0,0);
|
|
324 |
t1+=TTimeIntervalDays(1);
|
|
325 |
test(t1==t2);
|
|
326 |
|
|
327 |
dt=t1.DateTime();
|
|
328 |
dttest(dt,2001,3,1,0,0,0,0);
|
|
329 |
|
|
330 |
// 28/2/2004 29/2/2004
|
|
331 |
t1.Set(_L("20040127:"));
|
|
332 |
test(t2.Set(_L("20040128:"))==KErrNone);
|
|
333 |
test(Time::IsLeapYear(t1.DateTime().Year()));
|
|
334 |
test(t2.DaysFrom(t1)==TTimeIntervalDays(1));
|
|
335 |
dt=t1.DateTime();
|
|
336 |
dttest(dt,2004,2,28,0,0,0,0);
|
|
337 |
t1+=TTimeIntervalMinutes(60*24);
|
|
338 |
test(t1==t2);
|
|
339 |
dt=t2.DateTime();
|
|
340 |
dttest(dt,2004,2,29,0,0,0,0);
|
|
341 |
|
|
342 |
// 29/2/2004 & 1/3/2004
|
|
343 |
test(t1.Set(_L("20040128:"))==KErrNone);
|
|
344 |
test(t2.Set(_L("20040200:"))==KErrNone);
|
|
345 |
test(Time::IsLeapYear(t2.DateTime().Year()));
|
|
346 |
dt=t1.DateTime();
|
|
347 |
dttest(dt,2004,2,29,0,0,0,0);
|
|
348 |
t1+=TTimeIntervalSeconds(60*60*24);
|
|
349 |
test(t1==t2);
|
|
350 |
dt=t1.DateTime();
|
|
351 |
dttest(dt,2004,3,1,0,0,0,0);
|
|
352 |
|
|
353 |
}
|
|
354 |
|
|
355 |
void TestY2K::Test2()
|
|
356 |
{
|
|
357 |
// Test the input of valid and invalid dates to TDateTime and TTime
|
|
358 |
// Section 4.2
|
|
359 |
|
|
360 |
TTime t1,t2;
|
|
361 |
TDateTime dt;
|
|
362 |
// 31/12/1998
|
|
363 |
test(dt.Set(1998,EDecember,30,0,0,0,0)==KErrNone);
|
|
364 |
test(t1.Set(_L("19981130:"))==KErrNone);
|
|
365 |
dttest(dt,1998,12,31,0,0,0,0);
|
|
366 |
|
|
367 |
// 1/3/1999
|
|
368 |
test(dt.Set(1999,EMarch,0,0,0,0,0)==KErrNone);
|
|
369 |
test(t1.Set(_L("19990200:"))==KErrNone);
|
|
370 |
dttest(dt,1999,3,1,0,0,0,0);
|
|
371 |
|
|
372 |
// 27/2/2000
|
|
373 |
test(dt.Set(2000,EFebruary,26,0,0,0,0)==KErrNone);
|
|
374 |
test(t1.Set(_L("20000126:"))==KErrNone);
|
|
375 |
dttest(dt,2000,2,27,0,0,0,0);
|
|
376 |
|
|
377 |
// 31/12/2000
|
|
378 |
test(dt.Set(2000,EDecember,30,0,0,0,0)==KErrNone);
|
|
379 |
test(t1.Set(_L("20001130:225645."))==KErrNone);
|
|
380 |
dttest(dt,2000,12,31,0,0,0,0);
|
|
381 |
|
|
382 |
// 28/2/2004
|
|
383 |
test(dt.Set(2004,EFebruary,27,1,2,3,4)==KErrNone);
|
|
384 |
test(t1.Set(_L("20040127:"))==KErrNone);
|
|
385 |
dttest(dt,2004,2,28,1,2,3,4);
|
|
386 |
|
|
387 |
// 1/1/1999
|
|
388 |
test(dt.Set(1999,EJanuary,0,0,0,0,0)==KErrNone);
|
|
389 |
test(t1.Set(_L("19990000:"))==KErrNone);
|
|
390 |
dttest(dt,1999,1,1,0,0,0,0);
|
|
391 |
|
|
392 |
// 9/9/1999
|
|
393 |
test(dt.Set(1999,ESeptember,8,0,0,0,0)==KErrNone);
|
|
394 |
test(t1.Set(_L("19990808:"))==KErrNone);
|
|
395 |
dttest(dt,1999,9,9,0,0,0,0);
|
|
396 |
|
|
397 |
// 28/2/2000
|
|
398 |
test(dt.Set(2000,EFebruary,27,0,0,0,0)==KErrNone);
|
|
399 |
test(t1.Set(_L("20000127:"))==KErrNone);
|
|
400 |
dttest(dt,2000,2,28,0,0,0,0);
|
|
401 |
|
|
402 |
// 1/1/2001
|
|
403 |
test(dt.Set(2001,EJanuary,0,0,0,0,0)==KErrNone);
|
|
404 |
test(t1.Set(_L("20010000:"))==KErrNone);
|
|
405 |
dttest(dt,2001,1,1,0,0,0,0);
|
|
406 |
|
|
407 |
// 29/2/2004
|
|
408 |
test(dt.Set(2004,EFebruary,28,2,3,4,5)==KErrNone);
|
|
409 |
test(t1.Set(_L("20040128:"))==KErrNone);
|
|
410 |
dttest(dt,2004,2,29,2,3,4,5);
|
|
411 |
|
|
412 |
// 27/2/1999
|
|
413 |
test(dt.Set(1999,EFebruary,26,0,0,0,0)==KErrNone);
|
|
414 |
test(t1.Set(_L("19990126:"))==KErrNone);
|
|
415 |
dttest(dt,1999,2,27,0,0,0,0);
|
|
416 |
|
|
417 |
// 31/12/1999
|
|
418 |
test(dt.Set(1999,EDecember,30,0,0,0,0)==KErrNone);
|
|
419 |
test(t1.Set(_L("19991130:"))==KErrNone);
|
|
420 |
dttest(dt,1999,12,31,0,0,0,0);
|
|
421 |
|
|
422 |
// 29/2/2000
|
|
423 |
test(dt.Set(2000,EFebruary,28,0,0,0,0)==KErrNone);
|
|
424 |
test(t1.Set(_L("20000128:"))==KErrNone);
|
|
425 |
dttest(dt,2000,2,29,0,0,0,0);
|
|
426 |
|
|
427 |
// 28/2/2001
|
|
428 |
test(dt.Set(2001,EFebruary,27,0,0,0,0)==KErrNone);
|
|
429 |
test(t1.Set(_L("20010127:"))==KErrNone);
|
|
430 |
dttest(dt,2001,2,28,0,0,0,0);
|
|
431 |
|
|
432 |
// 1/3/2004
|
|
433 |
test(dt.Set(2004,EMarch,0,0,0,0,0)==KErrNone);
|
|
434 |
test(t1.Set(_L("20040200:"))==KErrNone);
|
|
435 |
dttest(dt,2004,3,1,0,0,0,0);
|
|
436 |
|
|
437 |
// 28/2/1999
|
|
438 |
test(dt.Set(1999,EFebruary,27,0,0,0,0)==KErrNone);
|
|
439 |
test(t1.Set(_L("19990127:"))==KErrNone);
|
|
440 |
dttest(dt,1999,2,28,0,0,0,0);
|
|
441 |
|
|
442 |
// 1/1/2000
|
|
443 |
test(dt.Set(2000,EJanuary,0,0,0,0,0)==KErrNone);
|
|
444 |
test(t1.Set(_L("20000000:"))==KErrNone);
|
|
445 |
dttest(dt,2000,1,1,0,0,0,0);
|
|
446 |
|
|
447 |
// 1/3/2000
|
|
448 |
test(dt.Set(2000,EMarch,0,0,0,0,0)==KErrNone);
|
|
449 |
test(t1.Set(_L("20000200:"))==KErrNone);
|
|
450 |
dttest(dt,2000,3,1,0,0,0,0);
|
|
451 |
|
|
452 |
// 1/3/2001
|
|
453 |
test(dt.Set(2001,EMarch,0,0,0,0,0)==KErrNone);
|
|
454 |
test(t1.Set(_L("20010200:"))==KErrNone);
|
|
455 |
dttest(dt,2001,3,1,0,0,0,0);
|
|
456 |
|
|
457 |
// Invalid dates
|
|
458 |
// 31/4/1998
|
|
459 |
test(dt.Set(1998,EApril,30,0,0,0,0)!=KErrNone);
|
|
460 |
test(t1.Set(_L("19980330:"))!=KErrNone);
|
|
461 |
dt=t1.DateTime();
|
|
462 |
dttest(dt,2001,3,1,0,0,0,0);
|
|
463 |
|
|
464 |
// 30/2/2000
|
|
465 |
test(dt.Set(2000,EFebruary,29,0,0,0,0)!=KErrNone);
|
|
466 |
test(t1.Set(_L("20000129:"))!=KErrNone);
|
|
467 |
dt=t1.DateTime();
|
|
468 |
dttest(dt,2001,3,1,0,0,0,0);
|
|
469 |
|
|
470 |
// 29/2/2001
|
|
471 |
test(dt.Set(2001,EFebruary,28,0,0,0,0)!=KErrNone);
|
|
472 |
test(t1.Set(_L("20010128:"))!=KErrNone);
|
|
473 |
dt=t1.DateTime();
|
|
474 |
dttest(dt,2001,3,1,0,0,0,0);
|
|
475 |
|
|
476 |
// 29/2/1999
|
|
477 |
test(dt.Set(1999,EFebruary,28,0,0,0,0)!=KErrNone);
|
|
478 |
test(t1.Set(_L("19990128:"))!=KErrNone);
|
|
479 |
dt=t1.DateTime();
|
|
480 |
dttest(dt,2001,3,1,0,0,0,0);
|
|
481 |
|
|
482 |
// 30/2/2004
|
|
483 |
test(dt.Set(2004,EFebruary,29,0,0,0,0)!=KErrNone);
|
|
484 |
test(t1.Set(_L("20040129:"))!=KErrNone);
|
|
485 |
dt=t1.DateTime();
|
|
486 |
dttest(dt,2001,3,1,0,0,0,0);
|
|
487 |
|
|
488 |
// test of TTime::Parse
|
|
489 |
// Set UniversalTime to C19 first
|
|
490 |
TTime oldtime;
|
|
491 |
oldtime.UniversalTime();
|
|
492 |
t1.Set(_L("19990303:"));
|
|
493 |
test(User::SetUTCTime(t1)==KErrNone);
|
|
494 |
|
|
495 |
test(t1.Parse(_L("1/1/00"))>=0);
|
|
496 |
dt=t1.DateTime();
|
|
497 |
dttest(dt,1900,1,1,0,0,0,0);
|
|
498 |
test(t1.Parse(_L("1/1/00"),1)>=0);
|
|
499 |
dt=t1.DateTime();
|
|
500 |
dttest(dt,2000,1,1,0,0,0,0);
|
|
501 |
|
|
502 |
test(t1.Parse(_L("2/3/2000"),20)>=0);
|
|
503 |
dt=t1.DateTime();
|
|
504 |
dttest(dt,2000,3,2,0,0,0,0);
|
|
505 |
|
|
506 |
test(t1.Parse(_L("31/12/99"),50)>=0);
|
|
507 |
dt=t1.DateTime();
|
|
508 |
dttest(dt,1999,12,31,0,0,0,0);
|
|
509 |
|
|
510 |
test(t1.Parse(_L("1/1/99"))>=0);
|
|
511 |
dt=t1.DateTime();
|
|
512 |
dttest(dt,1999,1,1,0,0,0,0);
|
|
513 |
|
|
514 |
test(t1.Parse(_L("1/1/99"),98)>=0);
|
|
515 |
dt=t1.DateTime();
|
|
516 |
TBuf<100> str;
|
|
517 |
t1.FormatL(str,_L("%F %D %M %Y %H:%T:%S.%C"));
|
|
518 |
test.Printf(str);
|
|
519 |
test.Printf(_L("\n"));
|
|
520 |
dttest(dt,1999,1,1,0,0,0,0);
|
|
521 |
|
|
522 |
// Reset UniversalTime
|
|
523 |
test(User::SetUTCTime(oldtime) == KErrNone);
|
|
524 |
|
|
525 |
// Year lengths
|
|
526 |
t1.Set(_L("20000000:"));
|
|
527 |
t2.Set(_L("20001130:"));
|
|
528 |
test(t2.DaysFrom(t1)==TTimeIntervalDays(365));
|
|
529 |
test(Time::IsLeapYear(t1.DateTime().Year()));
|
|
530 |
test(Time::IsLeapYear(t2.DateTime().Year()));
|
|
531 |
t1.Set(_L("20000100:"));
|
|
532 |
test(t1.DaysInMonth()==29);
|
|
533 |
|
|
534 |
t1.Set(_L("19990000:"));
|
|
535 |
t2.Set(_L("19991130:"));
|
|
536 |
test(t2.DaysFrom(t1)==TTimeIntervalDays(364));
|
|
537 |
test(Time::IsLeapYear(t1.DateTime().Year())==EFalse);
|
|
538 |
test(Time::IsLeapYear(t2.DateTime().Year())==EFalse);
|
|
539 |
t1.Set(_L("19990100:"));
|
|
540 |
test(t1.DaysInMonth()==28);
|
|
541 |
|
|
542 |
t1.Set(_L("20040000:"));
|
|
543 |
t2.Set(_L("20041130:"));
|
|
544 |
test(t2.DaysFrom(t1)==TTimeIntervalDays(365));
|
|
545 |
test(Time::IsLeapYear(t2.DateTime().Year()));
|
|
546 |
test(Time::IsLeapYear(t1.DateTime().Year()));
|
|
547 |
t1.Set(_L("20040100:"));
|
|
548 |
test(t1.DaysInMonth()==29);
|
|
549 |
|
|
550 |
}
|
|
551 |
|
|
552 |
|
|
553 |
void TestY2K::Test3()
|
|
554 |
{
|
|
555 |
TTime t1,t2;
|
|
556 |
TDateTime dt;
|
|
557 |
|
|
558 |
// Test operator <=, >=, >, <, +, -
|
|
559 |
|
|
560 |
// mid 1999 to 31/12/1999
|
|
561 |
t1.Set(_L("19990620:145459."));
|
|
562 |
t2.Set(_L("19991130:"));
|
|
563 |
test(!(t1>t2));
|
|
564 |
test(t1<t2);
|
|
565 |
test(t1<=t2);
|
|
566 |
test(!(t1>=t2));
|
|
567 |
test(!(t1==t2));
|
|
568 |
|
|
569 |
t1-=TTimeIntervalSeconds(59);
|
|
570 |
t1-=TTimeIntervalMinutes(54);
|
|
571 |
t1-=TTimeIntervalHours(14);
|
|
572 |
t1=t1+TTimeIntervalDays(10);
|
|
573 |
t1+=TTimeIntervalMonths(5);
|
|
574 |
test(t1==t2);
|
|
575 |
t2.Set(_L("19990730:"));
|
|
576 |
t1-=TTimeIntervalMonths(4);
|
|
577 |
test(t1==t2);
|
|
578 |
|
|
579 |
// Mid 1999 to 1/1/2000
|
|
580 |
t1.Set(_L("19990500:"));
|
|
581 |
t2.Set(_L("20000000:"));
|
|
582 |
test(t2>t1);
|
|
583 |
test(t2>=t1);
|
|
584 |
test(!(t2<t1));
|
|
585 |
test(!(t2<=t1));
|
|
586 |
t1+=TTimeIntervalMonths(7);
|
|
587 |
test(t1==t2);
|
|
588 |
t2.Set(_L("19990707:020202.2"));
|
|
589 |
t1+=TTimeIntervalMicroSeconds(2);
|
|
590 |
t1=t1+TTimeIntervalSeconds(2)+TTimeIntervalMinutes(2)+TTimeIntervalHours(2);
|
|
591 |
t1-=TTimeIntervalDays(24);
|
|
592 |
t1-=TTimeIntervalMonths(4);
|
|
593 |
dt=t1.DateTime();
|
|
594 |
test(t1==t2);
|
|
595 |
|
|
596 |
// Mid 1999 to 20/2/2000
|
|
597 |
t1.Set(_L("19990819:"));
|
|
598 |
t2.Set(_L("20000119:"));
|
|
599 |
test(t1<t2);
|
|
600 |
test(t1<=t2);
|
|
601 |
test(!(t1>t2));
|
|
602 |
test(!(t1>=t2));
|
|
603 |
test(!(t1==t2));
|
|
604 |
t1+=TTimeIntervalMonths(5);
|
|
605 |
test(t1==t2);
|
|
606 |
t2.Set(_L("19990600:"));
|
|
607 |
t1-=TTimeIntervalMonths(7);
|
|
608 |
t1-=TTimeIntervalDays(19);
|
|
609 |
test(t1==t2);
|
|
610 |
|
|
611 |
// Mid 1999 to 1/3/2000
|
|
612 |
t1.Set(_L("19990700:122345."));
|
|
613 |
t2.Set(_L("20000200:122345."));
|
|
614 |
test(t1<t2);
|
|
615 |
test(t1<=t2);
|
|
616 |
test(!(t1>t2));
|
|
617 |
test(!(t1>=t2));
|
|
618 |
test(!(t1==t2));
|
|
619 |
t1+=TTimeIntervalMonths(7);
|
|
620 |
test(t1==t2);
|
|
621 |
t2.Set(_L("19990800:"));
|
|
622 |
t1-=TTimeIntervalMonths(6);
|
|
623 |
t1=t1-TTimeIntervalHours(12)-TTimeIntervalMinutes(23)-TTimeIntervalSeconds(45);
|
|
624 |
test(t1==t2);
|
|
625 |
|
|
626 |
// mid 1999 to 1/4/2000
|
|
627 |
t1.Set(_L("19990500:"));
|
|
628 |
t2.Set(_L("20000300:"));
|
|
629 |
test(t1<t2);
|
|
630 |
test(t1<=t2);
|
|
631 |
test(!(t1>t2));
|
|
632 |
test(!(t1>=t2));
|
|
633 |
test(!(t1==t2));
|
|
634 |
t1+=TTimeIntervalMonths(10);
|
|
635 |
test(t1==t2);
|
|
636 |
t2.Set(_L("19990600:"));
|
|
637 |
t1-=TTimeIntervalMonths(9);
|
|
638 |
test(t1==t2);
|
|
639 |
|
|
640 |
// Mid 1999 to Mid 2001
|
|
641 |
t1.Set(_L("19990620:"));
|
|
642 |
t2.Set(_L("20010620:"));
|
|
643 |
test(t1<t2);
|
|
644 |
test(t1<=t2);
|
|
645 |
test(!(t1>t2));
|
|
646 |
test(!(t1>=t2));
|
|
647 |
test(!(t1==t2));
|
|
648 |
t1+=TTimeIntervalMonths(24);
|
|
649 |
test(t1==t2);
|
|
650 |
t2.Set(_L("19990720:"));
|
|
651 |
t1-=TTimeIntervalMonths(23);
|
|
652 |
test(t1==t2);
|
|
653 |
|
|
654 |
// Mid 2000 to Mid 2001
|
|
655 |
t1.Set(_L("20000620:"));
|
|
656 |
t2.Set(_L("20010620:"));
|
|
657 |
test(t1<t2);
|
|
658 |
test(t1<=t2);
|
|
659 |
test(!(t1>t2));
|
|
660 |
test(!(t1>=t2));
|
|
661 |
test(!(t1==t2));
|
|
662 |
t1+=TTimeIntervalMonths(12);
|
|
663 |
test(t1==t2);
|
|
664 |
t2.Set(_L("20000720:"));
|
|
665 |
t1-=TTimeIntervalMonths(11);
|
|
666 |
test(t1==t2);
|
|
667 |
|
|
668 |
}
|
|
669 |
|
|
670 |
|
|
671 |
void TestY2K::Test4()
|
|
672 |
{
|
|
673 |
TTime t1;
|
|
674 |
TLocale loc;
|
|
675 |
|
|
676 |
loc.SetStartOfWeek(EMonday);
|
|
677 |
|
|
678 |
// 1/1/1900 was Mon
|
|
679 |
t1.Set(_L("19000000:"));
|
|
680 |
test(t1.DayNoInWeek()==EMonday);
|
|
681 |
|
|
682 |
// 28/2/1900 was Wed
|
|
683 |
t1.Set(_L("19000127:"));
|
|
684 |
test(t1.DayNoInWeek()==EWednesday);
|
|
685 |
|
|
686 |
// 1/3/1900 was Thur
|
|
687 |
t1.Set(_L("19000200:"));
|
|
688 |
test(t1.DayNoInWeek()==EThursday);
|
|
689 |
|
|
690 |
// 28/2/1999 is sun
|
|
691 |
t1.Set(_L("19990127:"));
|
|
692 |
test(t1.DayNoInWeek()==ESunday);
|
|
693 |
|
|
694 |
// 1/3/1999 is mon
|
|
695 |
t1.Set(_L("19990200:"));
|
|
696 |
test(t1.DayNoInWeek()==EMonday);
|
|
697 |
|
|
698 |
// 31/12/1999
|
|
699 |
t1.Set(_L("19991130:"));
|
|
700 |
test(t1.DayNoInWeek()==EFriday);
|
|
701 |
|
|
702 |
// 1/1/2000
|
|
703 |
t1.Set(_L("20000000:"));
|
|
704 |
test(t1.DayNoInWeek()==ESaturday);
|
|
705 |
|
|
706 |
// 28/2/2000
|
|
707 |
t1.Set(_L("20000127:"));
|
|
708 |
test(t1.DayNoInWeek()==EMonday);
|
|
709 |
|
|
710 |
// 29/2/2000
|
|
711 |
t1.Set(_L("20000128:"));
|
|
712 |
test(t1.DayNoInWeek()==ETuesday);
|
|
713 |
|
|
714 |
// 1/3/2000
|
|
715 |
t1.Set(_L("20000200:"));
|
|
716 |
test(t1.DayNoInWeek()==EWednesday);
|
|
717 |
|
|
718 |
// 1/1/2001
|
|
719 |
t1.Set(_L("20010000:"));
|
|
720 |
test(t1.DayNoInWeek()==EMonday);
|
|
721 |
|
|
722 |
// 28/2/2004
|
|
723 |
t1.Set(_L("20040127:"));
|
|
724 |
test(t1.DayNoInWeek()==ESaturday);
|
|
725 |
|
|
726 |
// 29/2/2004
|
|
727 |
t1.Set(_L("20040128:"));
|
|
728 |
test(t1.DayNoInWeek()==ESunday);
|
|
729 |
|
|
730 |
// 1/3/2004
|
|
731 |
t1.Set(_L("20040200:"));
|
|
732 |
test(t1.DayNoInWeek()==EMonday);
|
|
733 |
|
|
734 |
}
|
|
735 |
|
|
736 |
void TestY2K::Test5()
|
|
737 |
{
|
|
738 |
// Test various timer alarms -
|
|
739 |
// User::At, User::After, RTimer::At, RTimer::After
|
|
740 |
TTime t1,t2, oldtime;
|
|
741 |
TRequestStatus stat;
|
|
742 |
RTimer timer;
|
|
743 |
timer.CreateLocal();
|
|
744 |
const TInt sec=1000000;
|
|
745 |
oldtime.UniversalTime();
|
|
746 |
|
|
747 |
// Check that timers across the boundary work
|
|
748 |
// 31/12/1998 to 1/1/1999
|
|
749 |
t1.Set(_L("19981130:235959."));
|
|
750 |
t2.Set(_L("19990000:000001."));
|
|
751 |
test(User::SetUTCTime(t1)==KErrNone);
|
|
752 |
timer.At(stat,t2);
|
|
753 |
__TRACE_LINE;
|
|
754 |
User::WaitForRequest(stat);
|
|
755 |
t1.UniversalTime();
|
|
756 |
PrintTime(_L("t1"),t1);
|
|
757 |
PrintTime(_L("t2"),t2);
|
|
758 |
test(t1 >= t2);
|
|
759 |
test(stat==KErrNone);
|
|
760 |
timer.At(stat,t1);
|
|
761 |
__TRACE_LINE;
|
|
762 |
User::WaitForRequest(stat);
|
|
763 |
test(stat==KErrUnderflow);
|
|
764 |
t1.Set(_L("19981130:235959."));
|
|
765 |
t2.Set(_L("19990000:000001."));
|
|
766 |
test(User::SetUTCTime(t1)==KErrNone);
|
|
767 |
test(User::At(t2)==KErrNone);
|
|
768 |
t1.UniversalTime();
|
|
769 |
test(t1 >= t2);
|
|
770 |
test(User::At(t1) == KErrUnderflow);
|
|
771 |
|
|
772 |
// 31/12/1999 1/1/2000
|
|
773 |
t1.Set(_L("19991130:235959."));
|
|
774 |
t2.Set(_L("20000000:000000.0"));
|
|
775 |
test(User::SetUTCTime(t1)==KErrNone);
|
|
776 |
timer.At(stat,t2);
|
|
777 |
__TRACE_LINE;
|
|
778 |
User::WaitForRequest(stat);
|
|
779 |
test(stat==KErrNone);
|
|
780 |
t1.UniversalTime();
|
|
781 |
TBuf<100> str;
|
|
782 |
t1.FormatL(str,_L("%F %D %M %Y %H:%T:%S.%C"));
|
|
783 |
test.Printf(str);
|
|
784 |
test.Printf(_L("\n"));
|
|
785 |
test(t1>=t2);
|
|
786 |
timer.At(stat,t1);
|
|
787 |
__TRACE_LINE;
|
|
788 |
User::WaitForRequest(stat);
|
|
789 |
test(stat==KErrUnderflow);
|
|
790 |
t1.Set(_L("19991130:235959."));
|
|
791 |
t2.Set(_L("20000000:000000.00000"));
|
|
792 |
test(User::SetUTCTime(t1)==KErrNone);
|
|
793 |
test(User::At(t2)==KErrNone);
|
|
794 |
t1.UniversalTime();
|
|
795 |
test(t1>=t2);
|
|
796 |
|
|
797 |
// 31/12/2000 to 1/1/2001
|
|
798 |
t1.Set(_L("20001130:235958."));
|
|
799 |
t2.Set(_L("20010000:"));
|
|
800 |
test(User::SetUTCTime(t1)==KErrNone);
|
|
801 |
timer.At(stat,t2);
|
|
802 |
__TRACE_LINE;
|
|
803 |
User::WaitForRequest(stat);
|
|
804 |
test(stat==KErrNone);
|
|
805 |
t1.UniversalTime();
|
|
806 |
test(t1>=t2);
|
|
807 |
timer.At(stat,t1);
|
|
808 |
__TRACE_LINE;
|
|
809 |
User::WaitForRequest(stat);
|
|
810 |
test(stat==KErrUnderflow);
|
|
811 |
t1.Set(_L("20001130:235958."));
|
|
812 |
t2.Set(_L("20010000:"));
|
|
813 |
test(User::SetUTCTime(t1)==KErrNone);
|
|
814 |
test(User::At(t2)==KErrNone);
|
|
815 |
t1.UniversalTime();
|
|
816 |
test(t1>=t2);
|
|
817 |
|
|
818 |
// Check that tick timers across the C work
|
|
819 |
|
|
820 |
// 31/12/1998 & 1/1/1999
|
|
821 |
t1.Set(_L("19981130:235959."));
|
|
822 |
t2.Set(_L("19990000:"));
|
|
823 |
test(User::SetUTCTime(t1)==KErrNone);
|
|
824 |
timer.After(stat,sec*2);
|
|
825 |
__TRACE_LINE;
|
|
826 |
User::WaitForRequest(stat);
|
|
827 |
test(stat==KErrNone);
|
|
828 |
t1.UniversalTime();
|
|
829 |
test(t1>=t2);
|
|
830 |
t1.Set(_L("19981130:235959."));
|
|
831 |
t2.Set(_L("19990000:"));
|
|
832 |
test(User::SetUTCTime(t1)==KErrNone);
|
|
833 |
User::After(sec*2);
|
|
834 |
t1.UniversalTime();
|
|
835 |
test(t1>=t2);
|
|
836 |
t1.Set(_L("19981130:235959."));
|
|
837 |
t2.Set(_L("19990000:"));
|
|
838 |
test(User::SetUTCTime(t1)==KErrNone);
|
|
839 |
test(User::At(t2)==KErrNone);
|
|
840 |
t1.UniversalTime();
|
|
841 |
test(t1>=t2);
|
|
842 |
|
|
843 |
// 31/12/1999 & 1/1/2000
|
|
844 |
t1.Set(_L("19991130:235959."));
|
|
845 |
t2.Set(_L("20000000:"));
|
|
846 |
test(User::SetUTCTime(t1)==KErrNone);
|
|
847 |
timer.After(stat,sec*2);
|
|
848 |
__TRACE_LINE;
|
|
849 |
User::WaitForRequest(stat);
|
|
850 |
test(stat==KErrNone);
|
|
851 |
t1.UniversalTime();
|
|
852 |
test(t1>=t2);
|
|
853 |
t1.Set(_L("19991130:235959."));
|
|
854 |
t2.Set(_L("20000000:"));
|
|
855 |
test(User::SetUTCTime(t1)==KErrNone);
|
|
856 |
User::After(sec*2);
|
|
857 |
t1.UniversalTime();
|
|
858 |
test(t1>=t2);
|
|
859 |
t1.Set(_L("19991130:235959."));
|
|
860 |
t2.Set(_L("20000000:"));
|
|
861 |
test(User::SetUTCTime(t1)==KErrNone);
|
|
862 |
test(User::At(t2)==KErrNone);
|
|
863 |
t1.UniversalTime();
|
|
864 |
test(t1>=t2);
|
|
865 |
|
|
866 |
//31/12/2000 and 1/1/2001
|
|
867 |
t1.Set(_L("20001130:235959."));
|
|
868 |
t2.Set(_L("20010000:"));
|
|
869 |
test(User::SetUTCTime(t1)==KErrNone);
|
|
870 |
timer.After(stat, sec*5);
|
|
871 |
__TRACE_LINE;
|
|
872 |
User::WaitForRequest(stat);
|
|
873 |
test(stat==KErrNone);
|
|
874 |
t1.UniversalTime();
|
|
875 |
test(t1>=t2);
|
|
876 |
t1.Set(_L("20001130:235959."));
|
|
877 |
t2.Set(_L("20010000:"));
|
|
878 |
test(User::SetUTCTime(t1)==KErrNone);
|
|
879 |
User::After(sec*5);
|
|
880 |
t1.UniversalTime();
|
|
881 |
test(t1>=t2);
|
|
882 |
t1.Set(_L("20001130:235959."));
|
|
883 |
t2.Set(_L("20010000:"));
|
|
884 |
test(User::SetUTCTime(t1)==KErrNone);
|
|
885 |
test(User::At(t2)==KErrNone);
|
|
886 |
t1.UniversalTime();
|
|
887 |
test(t1>=t2);
|
|
888 |
|
|
889 |
// check that timers abort across the C, with timer b4 and after
|
|
890 |
// date changed to.
|
|
891 |
TTime times[4];
|
|
892 |
RTimer timers[3];
|
|
893 |
TRequestStatus stats[3];
|
|
894 |
TInt i;
|
|
895 |
|
|
896 |
for(i=0;i<3;i++)
|
|
897 |
timers[i].CreateLocal();
|
|
898 |
|
|
899 |
// 31/12/1998 & 1/1/1999
|
|
900 |
times[0].Set(_L("19981129:"));
|
|
901 |
times[1].Set(_L("19981130:235959.999999"));
|
|
902 |
times[2].Set(_L("19990203:234500."));
|
|
903 |
times[3].Set(_L("19990506:"));
|
|
904 |
|
|
905 |
test(User::SetUTCTime(times[0])==KErrNone);
|
|
906 |
for(i=1;i<4;i++)
|
|
907 |
timers[i-1].At(stats[i-1], times[i]);
|
|
908 |
User::SetUTCTime(times[2]);
|
|
909 |
// Should all abort
|
|
910 |
for(i=0;i<3;i++)
|
|
911 |
{
|
|
912 |
__TRACE_LINE;
|
|
913 |
User::WaitForRequest(stats[i]);
|
|
914 |
test(stats[1]==KErrAbort);
|
|
915 |
}
|
|
916 |
|
|
917 |
// 31/12/1999 & 1/1/2000
|
|
918 |
times[0].Set(_L("19991029:"));
|
|
919 |
times[1].Set(_L("19991130:235959.999999"));
|
|
920 |
times[2].Set(_L("20000203:234500."));
|
|
921 |
times[3].Set(_L("20000506:"));
|
|
922 |
|
|
923 |
test(User::SetUTCTime(times[0])==KErrNone);
|
|
924 |
for(i=1;i<4;i++)
|
|
925 |
timers[i-1].At(stats[i-1], times[i]);
|
|
926 |
User::SetUTCTime(times[2]);
|
|
927 |
// Should all abort
|
|
928 |
for(i=0;i<3;i++)
|
|
929 |
{
|
|
930 |
__TRACE_LINE;
|
|
931 |
User::WaitForRequest(stats[i]);
|
|
932 |
test(stats[1]==KErrAbort);
|
|
933 |
}
|
|
934 |
|
|
935 |
// 31/12/2000 and 1/1/2001
|
|
936 |
times[0].Set(_L("20001129:"));
|
|
937 |
times[1].Set(_L("20001130:235959.999999"));
|
|
938 |
times[2].Set(_L("20010203:234500."));
|
|
939 |
times[3].Set(_L("20010506:"));
|
|
940 |
|
|
941 |
test(User::SetUTCTime(times[0])==KErrNone);
|
|
942 |
for(i=1;i<4;i++)
|
|
943 |
timers[i-1].At(stats[i-1], times[i]);
|
|
944 |
User::SetUTCTime(times[2]);
|
|
945 |
// Should all abort
|
|
946 |
for(i=0;i<3;i++)
|
|
947 |
{
|
|
948 |
__TRACE_LINE;
|
|
949 |
User::WaitForRequest(stats[i]);
|
|
950 |
test(stats[1]==KErrAbort);
|
|
951 |
}
|
|
952 |
|
|
953 |
// Check that overflow works
|
|
954 |
t1.Set(_L("99991130:"));
|
|
955 |
test(User::At(t1)==KErrOverflow);
|
|
956 |
test(User::SetUTCTime(oldtime)==KErrNone);
|
|
957 |
}
|
|
958 |
|
|
959 |
GLDEF_C TInt E32Main()
|
|
960 |
{
|
|
961 |
|
|
962 |
TTime oldtime;
|
|
963 |
oldtime.UniversalTime();
|
|
964 |
test.Title();
|
|
965 |
test.Start(_L("Testing Y2K behaviour"));
|
|
966 |
TestY2K T;
|
|
967 |
TLocale currentLocale;
|
|
968 |
|
|
969 |
TLocale b;
|
|
970 |
b.SetDateSeparator('\0',0);
|
|
971 |
b.SetDateSeparator('/',1);
|
|
972 |
b.SetDateSeparator('/',2);
|
|
973 |
b.SetDateSeparator('\0',3);
|
|
974 |
b.SetDateFormat(EDateEuropean);
|
|
975 |
b.SetTimeFormat(ETime12);
|
|
976 |
b.SetTimeSeparator('\0',0);
|
|
977 |
b.SetTimeSeparator(':',1);
|
|
978 |
b.SetTimeSeparator(':',2);
|
|
979 |
b.SetTimeSeparator('\0',3);
|
|
980 |
b.SetAmPmSpaceBetween(ETrue);
|
|
981 |
b.SetAmPmSymbolPosition(ELocaleAfter);
|
|
982 |
b.SetWorkDays(0x1F);
|
|
983 |
b.SetStartOfWeek(EMonday);
|
|
984 |
b.Set();
|
|
985 |
|
|
986 |
TTimeIntervalSeconds oldOffset = User::UTCOffset();
|
|
987 |
User::SetUTCOffset(0);
|
|
988 |
|
|
989 |
test.Next(_L("Testing TTime & TDateTime class (section 4.1.1.1)"));
|
|
990 |
T.Test1();
|
|
991 |
test.Next(_L("Testing TDateTime & TTime with valid and invalid dates (Section 4.2)"));
|
|
992 |
T.Test2();
|
|
993 |
test.Next(_L("Testing TDateTime & TTime with sorts/calculations (Section 4.2.5)"));
|
|
994 |
T.Test3();
|
|
995 |
test.Next(_L("Testing week days (Section 4.2.6)"));
|
|
996 |
T.Test4();
|
|
997 |
test.Next(_L("Testing timers"));
|
|
998 |
T.Test5();
|
|
999 |
test.Next(_L("Checking we can set to 31/12/1999 and 29/2/2000"));
|
|
1000 |
TTime t1;
|
|
1001 |
t1.Set(_L("19991130:"));
|
|
1002 |
User::SetUTCTime(t1);
|
|
1003 |
t1.UniversalTime();
|
|
1004 |
TBuf<100> str;
|
|
1005 |
t1.FormatL(str,_L("%F %D %M %Y %H:%T:%S.%C"));
|
|
1006 |
test.Printf(str);
|
|
1007 |
test.Printf(_L("\n"));
|
|
1008 |
t1.Set(_L("20000128:"));
|
|
1009 |
User::SetUTCTime(t1);
|
|
1010 |
t1.UniversalTime();
|
|
1011 |
t1.FormatL(str,_L("%F %D %M %Y %H:%T:%S.%C"));
|
|
1012 |
test.Printf(str);
|
|
1013 |
test.Printf(_L("\n"));
|
|
1014 |
//test.Printf(_L("Press a key"));
|
|
1015 |
//test.Getch();
|
|
1016 |
User::SetUTCTime(oldtime);
|
|
1017 |
currentLocale.Set();
|
|
1018 |
User::SetUTCOffset(oldOffset);
|
|
1019 |
test.End();
|
|
1020 |
return (0);
|
|
1021 |
}
|