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 

How to get Time in seconds??

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



Joined: 25 Feb 2007
Posts: 2

PostPosted: Sun Feb 25, 2007 3:38 am    Post subject: How to get Time in seconds?? Reply with quote

Sorry for maybe lame question. I'm using Old School library, and i'm newbie at C\C++ programming. And there is so little examples for psp SDK, and i still cannot properly read header files.

PLease help me. I would be very greatfull for function that will return time in sec. Thx!
Back to top
View user's profile Send private message
TyRaNiD



Joined: 18 Jan 2004
Posts: 918

PostPosted: Sun Feb 25, 2007 7:20 am    Post subject: Reply with quote

time_t t = time(NULL); perhaps ? :)
Back to top
View user's profile Send private message
Compozitor



Joined: 25 Feb 2007
Posts: 2

PostPosted: Tue Feb 27, 2007 8:39 am    Post subject: Reply with quote

Thank you! Sorry one more time. Can someone write here how to get milliseconds?? Thx!
Back to top
View user's profile Send private message
dot_blank



Joined: 28 Sep 2005
Posts: 498
Location: Brasil

PostPosted: Tue Feb 27, 2007 11:44 am    Post subject: Reply with quote

these posts only create the spiraling effect
you dont know how to get milliseconds now
then you need to know how to view contents of
a directory for a file browser or you might not
know how to sort filenames ...the point is that
this site is not here for rudimentary programming
exercises ...those things are best learnt somewhere
else where we ALL have learnt them ...from books
from online articles, tutorials of all natures ...so before
i will allow this spiraling to happen to you ...go do your
part in your understanding

go do some research :)
start of with the simple stuff and you will know
more questions and not more answers
http://www.cplusplus.com
_________________
10011011 00101010 11010111 10001001 10111010
Back to top
View user's profile Send private message
Cy-4AH



Joined: 31 Jan 2007
Posts: 44
Location: Belarus

PostPosted: Thu Mar 01, 2007 2:18 am    Post subject: Reply with quote

I have problem, there is code:
Code:
        char str_today[128];
        time_t now;
        tm *today;
        time(&now);
        today = localtime(&now);
        timeval tv;
        timezone tz;
        sceKernelLibcGettimeofday(&tv, &tz);
        pspDebugScreenSetXY(0,0);
        strftime(str_today, sizeof(str_today), "%d.%m.%Y %H:%M:%S %c %X", today);
        printf("%s\n%s\n", str_today, ctime(&now));
        printf("%d %d\n", tz.tz_minuteswest, tz.tz_dsttime);

So, the problem is that localtime don't correct time to my local time and tz.tz_minuteswest is equals to 0;
But I know that in psp settings GMT+2.00 and main meny showing me right time.
Of course I can add 2 hours, but it's not beatifully.
Back to top
View user's profile Send private message
adrahil



Joined: 16 Mar 2006
Posts: 277

PostPosted: Thu Mar 01, 2007 2:40 am    Post subject: Reply with quote

/me hangs himself on to a tree...
Back to top
View user's profile Send private message
Cy-4AH



Joined: 31 Jan 2007
Posts: 44
Location: Belarus

PostPosted: Thu Mar 01, 2007 4:08 am    Post subject: Reply with quote

adrahil wrote:
/me hangs himself on to a tree...

adrahil, plz, don't kill yourself. I had found already, that instead using time.h and time() we mast use psprtc.h and sceRtcGetCurrentClockLocalTime();
I'll delete this post.
Back to top
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Thu Mar 01, 2007 5:14 am    Post subject: Reply with quote

Perhaps when people ask questions like "how do I get the time?" we should just always post this:

http://psp.jim.sh/pspsdk-doc/
Back to top
View user's profile Send private message AIM Address
jimparis



Joined: 10 Jun 2005
Posts: 1179
Location: Boston

PostPosted: Thu Mar 01, 2007 5:51 am    Post subject: Reply with quote

Calm down, guys, it was a legit question, even though it's been answered on these forums before.

Cy-4AH, you have to call "tzset()" to set up the timezone in newlib.
It will initialize it automatically using the PSP's timezone settings.

See this post for more details: http://forums.ps2dev.org/viewtopic.php?t=3587&highlight=tzset
Back to top
View user's profile Send private message
Cy-4AH



Joined: 31 Jan 2007
Posts: 44
Location: Belarus

PostPosted: Thu Mar 01, 2007 6:57 pm    Post subject: Reply with quote

J.F. wrote:
Perhaps when people ask questions like "how do I get the time?" we should just always post this:

http://psp.jim.sh/pspsdk-doc/

J.F.Of course I use pspsdk-doc. Do you think that I just imagened functions time and localtime and they magicaly begin work?
If you look in pspsdk-doc at time.h you'll see that there is nothing usefull, only functions prototypes and function tzset not even mentioned Don't believe? . Look http://psp.jim.sh/pspsdk-doc/time_8h.html. So I looked in MSDN and didn't noticed tzset :)
May be you should add to sdk: "Before using localtime call tzset to set your local zone".
Back to top
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Fri Mar 02, 2007 11:14 am    Post subject: Reply with quote

Cy-4AH wrote:
J.F. wrote:
Perhaps when people ask questions like "how do I get the time?" we should just always post this:

http://psp.jim.sh/pspsdk-doc/

J.F.Of course I use pspsdk-doc. Do you think that I just imagened functions time and localtime and they magicaly begin work?
If you look in pspsdk-doc at time.h you'll see that there is nothing usefull, only functions prototypes and function tzset not even mentioned Don't believe? . Look http://psp.jim.sh/pspsdk-doc/time_8h.html. So I looked in MSDN and didn't noticed tzset :)
May be you should add to sdk: "Before using localtime call tzset to set your local zone".


Notice I said questions LIKE that one, not that one itself. :)

And it's good you use the docs... just be sure to mention that along with the question so that people know you aren't just being lazy. :D
Back to top
View user's profile Send private message AIM Address
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