retrieving handset time using systemfiles

Login to reply to this topic.
Thu, 2005-09-15 06:52
Joined: 2004-12-23
Forum posts: 239
Hi All

How can I retreive handset time using systemfiles.
Any idea or some help.
Thanks

---------------
Bhatt Kavita


Thu, 2005-09-15 08:13
Joined: 2005-07-13
Forum posts: 75
Re: retrieving handset time using systemfiles
I used something like this (I just copied straight from my prog, so sorry im in a rush tho! :p  )

LPTSTR GetCurrentTimeStr()
{
   char buff[512];
   LPTSTR szTime = NULL;
   time_t result;
   PTIME loctime;

   result = time(NULL);

   loctime = localtime(&result);

   sprintf(buff, "%s-%s-%s %s:%s:%s", CheckForDigit((loctime->tm_year)+1900), CheckForDigit(loctime->tm_mon+1), CheckForDigit(loctime->tm_mday), CheckForDigit(loctime->tm_hour), CheckForDigit(loctime->tm_min), CheckForDigit(loctime->tm_sec));
   
   szTime = (LPTSTR) malloc((strlen(buff)+1)*sizeof(WCHAR));

   mbstowcs(szTime, buff, strlen(buff));

   szTime[strlen(buff)] = 0;

   return szTime;
}

char *CheckForDigit(int iTime)
{
   char buff[10];
   char *szRet;

   if (iTime < 10)
      sprintf(buff, "0%i", iTime);
   else
      sprintf(buff, "%i", iTime);

   szRet = new char[strlen(buff)+1];

   strcpy(szRet, buff);
   
   szRet[strlen(buff)] = 0;

   return szRet;
}

include time.h and link against estlib.lib

hope this helps (sorry cant explain a bit more!)
R

"beer is proof that god loves us, and wants us to be happy!"

Thu, 2005-09-15 08:20
Joined: 2003-12-05
Forum posts: 672
Re: retrieving handset time using systemfiles
Quote from: mesweetie
Hi All
How can I retreive handset time using systemfiles.
Any idea or some help.
Thanks


TTime now;
now.HomeTime();

Thu, 2005-09-15 09:18
Joined: 2005-02-11
Forum posts: 214
Re: retrieving handset time using systemfiles
Or...
Code:
TTime now;
now.HomeTime();
TBuf<25> timeAsText;
_LIT(KDateString," %D%M%Y%/0%1%/1%2%/2%3%/3 %H:%T");
now.FormatL(timeAsText,KDateString);


"I only know that I know nothing." (Socrates)

  • Login to reply to this topic.