forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

time() function returns date in 1970

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
carlosedp



Joined: 19 Jun 2007
Posts: 21
Location: Sao Paulo / Brazil

PostPosted: Wed Jun 20, 2007 10:31 pm    Post subject: time() function returns date in 1970 Reply with quote

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
View user's profile Send private message
sakya



Joined: 28 Apr 2006
Posts: 190

PostPosted: Wed Jun 20, 2007 10:42 pm    Post subject: Re: time() function returns date in 1970 Reply with quote

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
View user's profile Send private message Visit poster's website
carlosedp



Joined: 19 Jun 2007
Posts: 21
Location: Sao Paulo / Brazil

PostPosted: Wed Jun 20, 2007 11:12 pm    Post subject: Reply with quote

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
View user's profile Send private message
sakya



Joined: 28 Apr 2006
Posts: 190

PostPosted: Wed Jun 20, 2007 11:28 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
carlosedp



Joined: 19 Jun 2007
Posts: 21
Location: Sao Paulo / Brazil

PostPosted: Thu Jun 21, 2007 1:26 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group