| View previous topic :: View next topic |
| Author |
Message |
carlosedp
Joined: 19 Jun 2007 Posts: 21 Location: Sao Paulo / Brazil
|
Posted: Wed Jun 20, 2007 10:31 pm Post subject: time() function returns date in 1970 |
|
|
I'm working on the port of Stackless for PSP.. I found out a problem where I could replicate in a small C app. When calling the time() function, it returns me the time in GMT but the date is 01/01/1970.
If I substituted the time() function by sceKernelLibcTime() function, it returns me the correct time and date but in GMT.
Reading the forums I saw that if I call tzset(), It would grab PSP timezone and apply it correctly but its not working... even calling tzset() the time is still in GMT.
Here is the small case:
| Code: |
int main() {
pspDebugScreenInit();
SetupCallbacks();
tzset(); // <- does nothing....
printf("Hello World");
time_t now;
//now = time(NULL); // <-date in 01/01/1970 and GMT time
now = sceKernelLibcTime(NULL); // -< date correct but time in GMT
printf("Started %s\n", ctime(&now));
sceKernelSleepThread();
return 0;
}
|
I'm using cygwin on windows XP, I have installed it from scratch and downloaded the toolchain from oopo website (psptoolchain-20070606.tar).
Thanks for any help,
Carlos
[/code] |
|
| Back to top |
|
 |
sakya
Joined: 28 Apr 2006 Posts: 190
|
Posted: Wed Jun 20, 2007 10:42 pm Post subject: Re: time() function returns date in 1970 |
|
|
Hi! :)
This works well for me:
| Code: | struct tm * ptm;
time_t mytime;
tzset();
time(&mytime);
ptm = localtime(&mytime);
pspDebugScreenSetXY(0, 0);
pspDebugScreenPrintf("%2.2d/%2.2d/%4.4d %2.2d:%2.2d",ptm->tm_mday, ptm->tm_mon + 1, ptm->tm_year + 1900, ptm->tm_hour,ptm->tm_min);
|
Ciaooo
Sakya |
|
| Back to top |
|
 |
carlosedp
Joined: 19 Jun 2007 Posts: 21 Location: Sao Paulo / Brazil
|
Posted: Wed Jun 20, 2007 11:12 pm Post subject: |
|
|
Same problem here... 01/01/1970 ... and time in GMT (here i'm GMT-3).
Maybe I have a problem in my environment... dunno because I have installed it all from scrach following the wiki.
If you could point me out what to check....
Thanks,
Carlos |
|
| Back to top |
|
 |
sakya
Joined: 28 Apr 2006 Posts: 190
|
Posted: Wed Jun 20, 2007 11:28 pm Post subject: |
|
|
Ciao! :)
| carlosedp wrote: | | If you could point me out what to check.... |
Sorry, I don't know. You need someone more expert. :)
I can tell you I'm using the devkit from xorloser on Windows XP.
http://xorloser.com/PSPDevWin32.zip
The code I posted works fine for me (GMT+1).
Ciaooo
Sakya |
|
| Back to top |
|
 |
carlosedp
Joined: 19 Jun 2007 Posts: 21 Location: Sao Paulo / Brazil
|
Posted: Thu Jun 21, 2007 1:26 am Post subject: |
|
|
Thanks a lot Sakya, It was a problem in my environment... I substituted the PSPDEV tree in my cygwin install and the time() function returned the correct time and date.
Thanks a lot for pointing out.
Carlos |
|
| Back to top |
|
 |
|