genericopenlibs/cstdlib/TSTLIB/T_PR234_LTIME.cpp
changeset 44 97b0fb8a2cc2
parent 0 e4d67989cc36
child 57 2efc27d87e1c
equal deleted inserted replaced
22:ddc455616bd6 44:97b0fb8a2cc2
   107 @SYMPREQ PREQ234
   107 @SYMPREQ PREQ234
   108 */
   108 */
   109 void Testtime()
   109 void Testtime()
   110 	{
   110 	{
   111 	test.Next(_L(" @SYMTestCaseID:SYSLIB-STDLIB-CT-0144 \ntesting time()...\n "));
   111 	test.Next(_L(" @SYMTestCaseID:SYSLIB-STDLIB-CT-0144 \ntesting time()...\n "));
   112 	RTz tz;
   112 	TInt r = KErrNone;
   113 	tz.Connect();
   113     RTz tz;
       
   114     r = tz.Connect();
       
   115     if (r != KErrNone)
       
   116         {
       
   117             User::Leave(r);
       
   118         }
   114 	CTzId* tzId = CTzId::NewL(2592); //set the timezone to Europe/London
   119 	CTzId* tzId = CTzId::NewL(2592); //set the timezone to Europe/London
   115 	CleanupStack::PushL(tzId);
   120 	CleanupStack::PushL(tzId);
   116 	tz.SetTimeZoneL(*tzId);
   121 	tz.SetTimeZoneL(*tzId);
   117 	TTime t,unix;
   122 	TTime t,unix;
   118 	unix.Set(priorUnixTime);
   123 	unix.Set(priorUnixTime);
   160 	{
   165 	{
   161 	test.Next(_L(" @SYMTestCaseID:SYSLIB-STDLIB-CT-0145  \ntesting toLocal()...\n "));
   166 	test.Next(_L(" @SYMTestCaseID:SYSLIB-STDLIB-CT-0145  \ntesting toLocal()...\n "));
   162 	
   167 	
   163 	//test when dst is on...
   168 	//test when dst is on...
   164 	test.Printf(_L("tests during summertime (dst on)...\t"));
   169 	test.Printf(_L("tests during summertime (dst on)...\t"));
       
   170 	
       
   171 	TInt rt = KErrNone;
       
   172 	TInt rz = KErrNone;
       
   173 	
   165 	//set the utc time to 8.55am, 15 May 2005 -Daylight savings apply on this date
   174 	//set the utc time to 8.55am, 15 May 2005 -Daylight savings apply on this date
   166 	TInt err=User::SetUTCTime(TTime(TDateTime(2005, EMay, 15, 8, 55, 0, 0)));
   175 	TInt err=User::SetUTCTime(TTime(TDateTime(2005, EMay, 15, 8, 55, 0, 0)));
   167 	test(err==0);
   176 	test(err==0);
   168 	RTz tz;
   177 	RTz tz;
   169 	tz.Connect();
   178     rt = tz.Connect();
       
   179     if (rt != KErrNone)
       
   180         {
       
   181             User::Leave(rt);
       
   182         }
   170 	CTzId* tzId = CTzId::NewL(2592); //set the timezone to Europe/London
   183 	CTzId* tzId = CTzId::NewL(2592); //set the timezone to Europe/London
   171 	CleanupStack::PushL(tzId);
   184 	CleanupStack::PushL(tzId);
   172 	tz.SetTimeZoneL(*tzId);
   185 	tz.SetTimeZoneL(*tzId);
   173 	CleanupStack::PopAndDestroy(tzId);
   186 	CleanupStack::PopAndDestroy(tzId);
   174 	tz.Close();
   187 	tz.Close();
   200 	//test when DST is off
   213 	//test when DST is off
   201 	test.Printf(_L("tests during wintertime (dst off)...\t"));
   214 	test.Printf(_L("tests during wintertime (dst off)...\t"));
   202 	err=User::SetUTCTime(TTime(TDateTime(2005, EJanuary, 15, 8, 55, 0, 0)));
   215 	err=User::SetUTCTime(TTime(TDateTime(2005, EJanuary, 15, 8, 55, 0, 0)));
   203 	test(err==0);
   216 	test(err==0);
   204 	
   217 	
   205 	tz.Connect();
   218     rz = tz.Connect();
       
   219     if (rz != KErrNone)
       
   220         {
       
   221             User::Leave(rz);
       
   222         }
       
   223     
   206 	CTzId* tzId2 = CTzId::NewL(2592); //set the timezone to Europe/London
   224 	CTzId* tzId2 = CTzId::NewL(2592); //set the timezone to Europe/London
   207 	CleanupStack::PushL(tzId2);
   225 	CleanupStack::PushL(tzId2);
   208 	tz.SetTimeZoneL(*tzId2);
   226 	tz.SetTimeZoneL(*tzId2);
   209 	CleanupStack::PopAndDestroy(tzId2);
   227 	CleanupStack::PopAndDestroy(tzId2);
   210 	tz.Close();
   228 	tz.Close();