sl@0: // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: sl@0: // This function is used to update month and day in aBufLocalTime sl@0: // to actual month and day to be passed to TTime() constructor. sl@0: // Remember using TTime::FormatL() in thelpers.cpp sl@0: // has added extra month and a day to aBufLocalTime. sl@0: // aBufLocalTime is in format YYMMDD:HHMMSS.MMMMMM sl@0: // see TTime::Set() for aBufLocalTime expected format details. sl@0: TInt UpdateToActualMonthAndDay(TDes& aBufUTCTime) sl@0: { sl@0: TInt mVal = 0; sl@0: TInt dVal = 0; sl@0: sl@0: TBuf <4> tempBuf; sl@0: _LIT(KFormat, "%02d"); sl@0: sl@0: //Get the position of colon separator sl@0: TInt colon = aBufUTCTime.Locate(':'); sl@0: sl@0: // Get Month & Day if Present sl@0: switch(colon) sl@0: { sl@0: case 0: break; sl@0: case 8: sl@0: { sl@0: TLex month = aBufUTCTime.Mid(4,2); sl@0: TLex day = aBufUTCTime.Mid(6,2); sl@0: month.Val(mVal); sl@0: day.Val(dVal); sl@0: } sl@0: break; sl@0: default: sl@0: { sl@0: // If the colon is at the wrong position sl@0: return (KErrArgument); sl@0: } sl@0: sl@0: } sl@0: sl@0: // Deduct extra month and a day and update aBufLocalTime sl@0: if(mVal > 0 && dVal > 0) sl@0: { sl@0: mVal-=1; sl@0: dVal-=1; sl@0: sl@0: tempBuf.Format(KFormat, mVal); sl@0: aBufUTCTime.Replace(4,2, tempBuf); sl@0: sl@0: tempBuf.Format(KFormat, dVal); sl@0: aBufUTCTime.Replace(6,2, tempBuf); sl@0: } sl@0: sl@0: return(KErrNone); sl@0: } sl@0: sl@0: GLDEF_C TInt E32Main() sl@0: { sl@0: TInt err = KErrNone; sl@0: TBuf<64> bufUTCTime; sl@0: sl@0: User::CommandLine(bufUTCTime); sl@0: err = UpdateToActualMonthAndDay(bufUTCTime); sl@0: sl@0: if( err == KErrNone) sl@0: { sl@0: TTime utcTime(bufUTCTime); sl@0: err = User::SetUTCTime(utcTime); sl@0: } sl@0: sl@0: return err; sl@0: } sl@0: