Update contrib.
1 // Copyright (c) 2005-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 "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.
19 // This function is used to update month and day in aBufLocalTime
20 // to actual month and day to be passed to TTime() constructor.
21 // Remember using TTime::FormatL() in thelpers.cpp
22 // has added extra month and a day to aBufLocalTime.
23 // aBufLocalTime is in format YYMMDD:HHMMSS.MMMMMM
24 // see TTime::Set() for aBufLocalTime expected format details.
25 TInt UpdateToActualMonthAndDay(TDes& aBufLocalTime)
31 _LIT(KFormat, "%02d");
33 //Get the position of colon separator
34 TInt colon = aBufLocalTime.Locate(':');
36 // Get Month & Day if Present
42 TLex month = aBufLocalTime.Mid(4,2);
43 TLex day = aBufLocalTime.Mid(6,2);
50 // If the colon is at the wrong position.
51 return (KErrArgument);
56 // Deduct extra month and a day and update aBufLocalTime
57 if(mVal > 0 && dVal > 0)
62 tempBuf.Format(KFormat, mVal);
63 aBufLocalTime.Replace(4,2, tempBuf);
65 tempBuf.Format(KFormat, dVal);
66 aBufLocalTime.Replace(6,2, tempBuf);
72 //This function is used in the test code to Set the system time to the given local time.
73 static TInt SetHomeTimeL(TTime& aLocalTime)
75 TInt retVal = KErrNone;
78 User::LeaveIfError(theTzSrv.Connect());
79 CleanupClosePushL(theTzSrv);
81 retVal = theTzSrv.SetHomeTime(aLocalTime);
83 CleanupStack::PopAndDestroy(); //theTzSrv.Close()
87 GLDEF_C TInt E32Main()
90 TInt retVal = KErrNone;
91 TBuf<64> bufLocalTime;
93 User::CommandLine(bufLocalTime);
95 retVal = UpdateToActualMonthAndDay(bufLocalTime);
97 if(retVal == KErrNone)
99 TTime localTime(bufLocalTime);
101 CTrapCleanup* cleanup = CTrapCleanup::New(); //can fail
104 TRAP(err, retVal = SetHomeTimeL(localTime))