| View previous topic :: View next topic |
| Author |
Message |
Compozitor
Joined: 25 Feb 2007 Posts: 2
|
Posted: Sun Feb 25, 2007 3:38 am Post subject: How to get Time in seconds?? |
|
|
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 |
|
 |
TyRaNiD
Joined: 18 Jan 2004 Posts: 918
|
Posted: Sun Feb 25, 2007 7:20 am Post subject: |
|
|
| time_t t = time(NULL); perhaps ? :) |
|
| Back to top |
|
 |
Compozitor
Joined: 25 Feb 2007 Posts: 2
|
Posted: Tue Feb 27, 2007 8:39 am Post subject: |
|
|
| Thank you! Sorry one more time. Can someone write here how to get milliseconds?? Thx! |
|
| Back to top |
|
 |
dot_blank

Joined: 28 Sep 2005 Posts: 498 Location: Brasil
|
Posted: Tue Feb 27, 2007 11:44 am Post subject: |
|
|
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 |
|
 |
Cy-4AH
Joined: 31 Jan 2007 Posts: 44 Location: Belarus
|
Posted: Thu Mar 01, 2007 2:18 am Post subject: |
|
|
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 |
|
 |
adrahil
Joined: 16 Mar 2006 Posts: 277
|
Posted: Thu Mar 01, 2007 2:40 am Post subject: |
|
|
| /me hangs himself on to a tree... |
|
| Back to top |
|
 |
Cy-4AH
Joined: 31 Jan 2007 Posts: 44 Location: Belarus
|
Posted: Thu Mar 01, 2007 4:08 am Post subject: |
|
|
| 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 |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Thu Mar 01, 2007 5:14 am Post subject: |
|
|
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 |
|
 |
jimparis
Joined: 10 Jun 2005 Posts: 1179 Location: Boston
|
Posted: Thu Mar 01, 2007 5:51 am Post subject: |
|
|
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 |
|
 |
Cy-4AH
Joined: 31 Jan 2007 Posts: 44 Location: Belarus
|
Posted: Thu Mar 01, 2007 6:57 pm Post subject: |
|
|
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 |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Fri Mar 02, 2007 11:14 am Post subject: |
|
|
| Cy-4AH wrote: |
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 |
|
 |
|