Update contrib.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32test\y2k\t_y2k.cpp
16 // Year 2000 compliance tests for E32
18 // TTime, TDateTime, RTimer
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:
29 // Assumptions/Requirement/Pre-requisites:
30 // Failures and causes:
31 // Base Port information:
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)
42 LOCAL_D RTest test(_L("T_Y2K"));
44 #define __TRACE_LINE test.Printf(_L("line %d\n"),__LINE__)
46 // test fields in TDateTime, using sensible dates (ie 1/1/1999 not 0/0/1999)
51 void Test1(); // test TTime for Y2K compliance
58 void PrintTime(const TDesC& aName, const TTime& aTime)
60 TDateTime dt(aTime.DateTime());
61 test.Printf(_L("%S = %02d:%02d:%02d:%06d\n"),&aName,dt.Hour(),dt.Minute(),dt.Second(),dt.MicroSecond());
66 // Test the T_Time & TDateTime classes in accordance with the test spec for Y2K
69 // 31/12/1998 and 1/1/1999
70 test.Next(_L("Testing existing functionality"));
75 test(t1.Set(_L("19981130:235959.999999"))==KErrNone);
76 test(t2.Set(_L("19990000:000000."))==KErrNone);
80 test(dt.Year()==1998);
81 test(dt.Month()==EDecember);
84 t1+=TTimeIntervalMicroSeconds(1);
87 dttest(dt,1999,1,1,0,0,0,0);
90 test(t1.Set(_L("19981130:235900.000000"))==KErrNone);
91 test(t2.Set(_L("19990000:000001.000000"))==KErrNone);
94 t1+=TTimeIntervalSeconds(61);
97 dttest(dt,1999,1,1,0,0,1,0);
100 t1.Set(_L("19981130:234500.000100"));
101 t2.Set(_L("19990000:000100.000100"));
102 t1+=TTimeIntervalMinutes(16);
105 dttest(dt,1999,1,1,0,1,0,100);
108 t1.Set(_L("19981130:230000.000001"));
109 t2.Set(_L("19990000:000000.000001"));
110 t1+=TTimeIntervalHours(1);
113 dttest(dt,1999,1,1,0,0,0,1);
116 t1.Set(_L("19990000:164523.101000"));
117 t2.Set(_L("19981130:164523.101000"));
118 t1-=TTimeIntervalDays(1);
121 dttest(dt,1998,12,31,16,45,23,101000);
124 t1.Set(_L("19990030:164523.999999"));
125 t2.Set(_L("19981130:164523.999999"));
126 t1-=TTimeIntervalMonths(1);
129 dttest(dt,1998,12,31,16,45,23,999999);
132 t1.Set(_L("19990000:235959.999999"));
133 t2.Set(_L("19980000:235959.999999"));
134 t1-=TTimeIntervalYears(1);
137 dttest(dt,1998,1,1,23,59,59,999999);
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);
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);
162 // 27/2/1998 & 28/2/1998
164 t1.Set(_L("19980126:144559.101000"));
165 t2.Set(_L("19980127:144559.101000"));
168 dttest(dt,1998,2,27,14,45,59,101000);
170 t1+=TTimeIntervalDays(1);
174 dttest(dt,1998,2,28,14,45,59,101000);
176 // 28/2/1998 & 1/3/1998
178 t1.Set(_L("19980127:"));
179 t2.Set(_L("19980200:"));
182 dttest(dt,1998,2,28,0,0,0,0);
184 t1+=TTimeIntervalDays(1);
188 dttest(dt,1998,3,1,0,0,0,0);
190 // 31/8/1999 & 1/9/1999
192 t1.Set(_L("19990730:235959.121200"));
193 t2.Set(_L("19990800:000000.121200"));
196 dttest(dt,1999,8,31,23,59,59,121200);
198 t1+=TTimeIntervalSeconds(1);
202 dttest(dt,1999,9,1,0,0,0,121200);
204 // 8/9/1999 & 9/9/1999
206 t1.Set(_L("19990807:233434."));
207 t2.Set(_L("19990808:003434."));
210 dttest(dt,1999,9,8,23,34,34,0);
212 t1+=TTimeIntervalHours(1);
216 dttest(dt,1999,9,9,0,34,34,0);
218 // 9/9/1999 & 10/9/1999
220 t1.Set(_L("19990808:235934."));
221 t2.Set(_L("19990809:000034."));
224 dttest(dt,1999,9,9,23,59,34,0);
226 t1+=TTimeIntervalMinutes(1);
230 dttest(dt,1999,9,10,0,0,34,0);
232 // 31/12/1999 & 1/1/2000
234 test(t1.Set(_L("19991130:"))==KErrNone);
235 test(t2.Set(_L("20000000:"))==KErrNone);
238 dttest(dt,1999,12,31,0,0,0,0);
240 t1+=TTimeIntervalDays(1);
244 dttest(dt,2000,1,1,0,0,0,0);
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);
255 test(t1.DayNoInYear()==1);
256 test(t1.WeekNoInYear(EFirstWeek)==1);
257 test(t2.DaysInMonth()==31);
259 // 27/2/2000 to 28/2/2000
261 test(t1.Set(_L("20000126:235958.999999"))==KErrNone);
262 test(t2.Set(_L("20000127:"))==KErrNone);
265 dttest(dt,2000,2,27,23,59,58,999999);
267 t1+=TTimeIntervalSeconds(1);
268 t1+=TTimeIntervalMicroSeconds(1);
270 test(t1.DaysInMonth()==29);
273 dttest(dt,2000,2,28,0,0,0,0);
275 // 28/2/2000 & 29/2/2000
277 test(t2.Set(_L("20000128:"))==KErrNone);
278 test(dt.Set(2000,EFebruary,28,0,0,0,0)==KErrNone);
280 t1+=TTimeIntervalDays(1);
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));
290 // 29/2/2000 to 1/3/2000
292 t1.Set(_L("20000128:"));
293 t2.Set(_L("20000200:"));
296 dttest(dt,2000,2,29,0,0,0,0);
297 t1+=TTimeIntervalHours(24);
300 dttest(dt,2000,3,1,0,0,0,0);
302 // 31/12/2000 & 1/1/2001
304 t1.Set(_L("20001130:"));
305 t2.Set(_L("20010000:235945."));
307 dttest(dt,2000,12,31,0,0,0,0);
309 t1+=TTimeIntervalHours(24);
310 t1+=TTimeIntervalMinutes(60*23);
311 t1+=TTimeIntervalSeconds(59*60+45);
315 dttest(dt,2001,1,1,23,59,45,0);
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));
323 dttest(dt,2001,2,28,0,0,0,0);
324 t1+=TTimeIntervalDays(1);
328 dttest(dt,2001,3,1,0,0,0,0);
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));
336 dttest(dt,2004,2,28,0,0,0,0);
337 t1+=TTimeIntervalMinutes(60*24);
340 dttest(dt,2004,2,29,0,0,0,0);
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()));
347 dttest(dt,2004,2,29,0,0,0,0);
348 t1+=TTimeIntervalSeconds(60*60*24);
351 dttest(dt,2004,3,1,0,0,0,0);
355 void TestY2K::Test2()
357 // Test the input of valid and invalid dates to TDateTime and TTime
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
459 test(dt.Set(1998,EApril,30,0,0,0,0)!=KErrNone);
460 test(t1.Set(_L("19980330:"))!=KErrNone);
462 dttest(dt,2001,3,1,0,0,0,0);
465 test(dt.Set(2000,EFebruary,29,0,0,0,0)!=KErrNone);
466 test(t1.Set(_L("20000129:"))!=KErrNone);
468 dttest(dt,2001,3,1,0,0,0,0);
471 test(dt.Set(2001,EFebruary,28,0,0,0,0)!=KErrNone);
472 test(t1.Set(_L("20010128:"))!=KErrNone);
474 dttest(dt,2001,3,1,0,0,0,0);
477 test(dt.Set(1999,EFebruary,28,0,0,0,0)!=KErrNone);
478 test(t1.Set(_L("19990128:"))!=KErrNone);
480 dttest(dt,2001,3,1,0,0,0,0);
483 test(dt.Set(2004,EFebruary,29,0,0,0,0)!=KErrNone);
484 test(t1.Set(_L("20040129:"))!=KErrNone);
486 dttest(dt,2001,3,1,0,0,0,0);
488 // test of TTime::Parse
489 // Set UniversalTime to C19 first
491 oldtime.UniversalTime();
492 t1.Set(_L("19990303:"));
493 test(User::SetUTCTime(t1)==KErrNone);
495 test(t1.Parse(_L("1/1/00"))>=0);
497 dttest(dt,1900,1,1,0,0,0,0);
498 test(t1.Parse(_L("1/1/00"),1)>=0);
500 dttest(dt,2000,1,1,0,0,0,0);
502 test(t1.Parse(_L("2/3/2000"),20)>=0);
504 dttest(dt,2000,3,2,0,0,0,0);
506 test(t1.Parse(_L("31/12/99"),50)>=0);
508 dttest(dt,1999,12,31,0,0,0,0);
510 test(t1.Parse(_L("1/1/99"))>=0);
512 dttest(dt,1999,1,1,0,0,0,0);
514 test(t1.Parse(_L("1/1/99"),98)>=0);
517 t1.FormatL(str,_L("%F %D %M %Y %H:%T:%S.%C"));
519 test.Printf(_L("\n"));
520 dttest(dt,1999,1,1,0,0,0,0);
522 // Reset UniversalTime
523 test(User::SetUTCTime(oldtime) == KErrNone);
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);
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);
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);
553 void TestY2K::Test3()
558 // Test operator <=, >=, >, <, +, -
560 // mid 1999 to 31/12/1999
561 t1.Set(_L("19990620:145459."));
562 t2.Set(_L("19991130:"));
569 t1-=TTimeIntervalSeconds(59);
570 t1-=TTimeIntervalMinutes(54);
571 t1-=TTimeIntervalHours(14);
572 t1=t1+TTimeIntervalDays(10);
573 t1+=TTimeIntervalMonths(5);
575 t2.Set(_L("19990730:"));
576 t1-=TTimeIntervalMonths(4);
579 // Mid 1999 to 1/1/2000
580 t1.Set(_L("19990500:"));
581 t2.Set(_L("20000000:"));
586 t1+=TTimeIntervalMonths(7);
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);
596 // Mid 1999 to 20/2/2000
597 t1.Set(_L("19990819:"));
598 t2.Set(_L("20000119:"));
604 t1+=TTimeIntervalMonths(5);
606 t2.Set(_L("19990600:"));
607 t1-=TTimeIntervalMonths(7);
608 t1-=TTimeIntervalDays(19);
611 // Mid 1999 to 1/3/2000
612 t1.Set(_L("19990700:122345."));
613 t2.Set(_L("20000200:122345."));
619 t1+=TTimeIntervalMonths(7);
621 t2.Set(_L("19990800:"));
622 t1-=TTimeIntervalMonths(6);
623 t1=t1-TTimeIntervalHours(12)-TTimeIntervalMinutes(23)-TTimeIntervalSeconds(45);
626 // mid 1999 to 1/4/2000
627 t1.Set(_L("19990500:"));
628 t2.Set(_L("20000300:"));
634 t1+=TTimeIntervalMonths(10);
636 t2.Set(_L("19990600:"));
637 t1-=TTimeIntervalMonths(9);
640 // Mid 1999 to Mid 2001
641 t1.Set(_L("19990620:"));
642 t2.Set(_L("20010620:"));
648 t1+=TTimeIntervalMonths(24);
650 t2.Set(_L("19990720:"));
651 t1-=TTimeIntervalMonths(23);
654 // Mid 2000 to Mid 2001
655 t1.Set(_L("20000620:"));
656 t2.Set(_L("20010620:"));
662 t1+=TTimeIntervalMonths(12);
664 t2.Set(_L("20000720:"));
665 t1-=TTimeIntervalMonths(11);
671 void TestY2K::Test4()
676 loc.SetStartOfWeek(EMonday);
679 t1.Set(_L("19000000:"));
680 test(t1.DayNoInWeek()==EMonday);
683 t1.Set(_L("19000127:"));
684 test(t1.DayNoInWeek()==EWednesday);
687 t1.Set(_L("19000200:"));
688 test(t1.DayNoInWeek()==EThursday);
691 t1.Set(_L("19990127:"));
692 test(t1.DayNoInWeek()==ESunday);
695 t1.Set(_L("19990200:"));
696 test(t1.DayNoInWeek()==EMonday);
699 t1.Set(_L("19991130:"));
700 test(t1.DayNoInWeek()==EFriday);
703 t1.Set(_L("20000000:"));
704 test(t1.DayNoInWeek()==ESaturday);
707 t1.Set(_L("20000127:"));
708 test(t1.DayNoInWeek()==EMonday);
711 t1.Set(_L("20000128:"));
712 test(t1.DayNoInWeek()==ETuesday);
715 t1.Set(_L("20000200:"));
716 test(t1.DayNoInWeek()==EWednesday);
719 t1.Set(_L("20010000:"));
720 test(t1.DayNoInWeek()==EMonday);
723 t1.Set(_L("20040127:"));
724 test(t1.DayNoInWeek()==ESaturday);
727 t1.Set(_L("20040128:"));
728 test(t1.DayNoInWeek()==ESunday);
731 t1.Set(_L("20040200:"));
732 test(t1.DayNoInWeek()==EMonday);
736 void TestY2K::Test5()
738 // Test various timer alarms -
739 // User::At, User::After, RTimer::At, RTimer::After
740 TTime t1,t2, oldtime;
744 const TInt sec=1000000;
745 oldtime.UniversalTime();
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);
754 User::WaitForRequest(stat);
756 PrintTime(_L("t1"),t1);
757 PrintTime(_L("t2"),t2);
759 test(stat==KErrNone);
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);
770 test(User::At(t1) == KErrUnderflow);
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);
778 User::WaitForRequest(stat);
779 test(stat==KErrNone);
782 t1.FormatL(str,_L("%F %D %M %Y %H:%T:%S.%C"));
784 test.Printf(_L("\n"));
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);
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);
803 User::WaitForRequest(stat);
804 test(stat==KErrNone);
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);
818 // Check that tick timers across the C work
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);
826 User::WaitForRequest(stat);
827 test(stat==KErrNone);
830 t1.Set(_L("19981130:235959."));
831 t2.Set(_L("19990000:"));
832 test(User::SetUTCTime(t1)==KErrNone);
836 t1.Set(_L("19981130:235959."));
837 t2.Set(_L("19990000:"));
838 test(User::SetUTCTime(t1)==KErrNone);
839 test(User::At(t2)==KErrNone);
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);
849 User::WaitForRequest(stat);
850 test(stat==KErrNone);
853 t1.Set(_L("19991130:235959."));
854 t2.Set(_L("20000000:"));
855 test(User::SetUTCTime(t1)==KErrNone);
859 t1.Set(_L("19991130:235959."));
860 t2.Set(_L("20000000:"));
861 test(User::SetUTCTime(t1)==KErrNone);
862 test(User::At(t2)==KErrNone);
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);
872 User::WaitForRequest(stat);
873 test(stat==KErrNone);
876 t1.Set(_L("20001130:235959."));
877 t2.Set(_L("20010000:"));
878 test(User::SetUTCTime(t1)==KErrNone);
882 t1.Set(_L("20001130:235959."));
883 t2.Set(_L("20010000:"));
884 test(User::SetUTCTime(t1)==KErrNone);
885 test(User::At(t2)==KErrNone);
889 // check that timers abort across the C, with timer b4 and after
893 TRequestStatus stats[3];
897 timers[i].CreateLocal();
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:"));
905 test(User::SetUTCTime(times[0])==KErrNone);
907 timers[i-1].At(stats[i-1], times[i]);
908 User::SetUTCTime(times[2]);
913 User::WaitForRequest(stats[i]);
914 test(stats[1]==KErrAbort);
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:"));
923 test(User::SetUTCTime(times[0])==KErrNone);
925 timers[i-1].At(stats[i-1], times[i]);
926 User::SetUTCTime(times[2]);
931 User::WaitForRequest(stats[i]);
932 test(stats[1]==KErrAbort);
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:"));
941 test(User::SetUTCTime(times[0])==KErrNone);
943 timers[i-1].At(stats[i-1], times[i]);
944 User::SetUTCTime(times[2]);
949 User::WaitForRequest(stats[i]);
950 test(stats[1]==KErrAbort);
953 // Check that overflow works
954 t1.Set(_L("99991130:"));
955 test(User::At(t1)==KErrOverflow);
956 test(User::SetUTCTime(oldtime)==KErrNone);
959 GLDEF_C TInt E32Main()
963 oldtime.UniversalTime();
965 test.Start(_L("Testing Y2K behaviour"));
967 TLocale currentLocale;
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);
983 b.SetStartOfWeek(EMonday);
986 TTimeIntervalSeconds oldOffset = User::UTCOffset();
987 User::SetUTCOffset(0);
989 test.Next(_L("Testing TTime & TDateTime class (section 4.1.1.1)"));
991 test.Next(_L("Testing TDateTime & TTime with valid and invalid dates (Section 4.2)"));
993 test.Next(_L("Testing TDateTime & TTime with sorts/calculations (Section 4.2.5)"));
995 test.Next(_L("Testing week days (Section 4.2.6)"));
997 test.Next(_L("Testing timers"));
999 test.Next(_L("Checking we can set to 31/12/1999 and 29/2/2000"));
1001 t1.Set(_L("19991130:"));
1002 User::SetUTCTime(t1);
1005 t1.FormatL(str,_L("%F %D %M %Y %H:%T:%S.%C"));
1007 test.Printf(_L("\n"));
1008 t1.Set(_L("20000128:"));
1009 User::SetUTCTime(t1);
1011 t1.FormatL(str,_L("%F %D %M %Y %H:%T:%S.%C"));
1013 test.Printf(_L("\n"));
1014 //test.Printf(_L("Press a key"));
1016 User::SetUTCTime(oldtime);
1017 currentLocale.Set();
1018 User::SetUTCOffset(oldOffset);