PDA

View Full Version : Time Zone



Art
July 22nd, 2007, 09:33
Here's how to get the time zone the PSP is set to in the XMB.
you shouldn't need it as a setting in the configuration file.


sceRtcGetCurrentClockLocalTime(&rtime); // calculate timezone
hhr = rtime.hour;
lochr = hhr;
sceRtcGetCurrentClock(&rtime,0);
utchour = rtime.hour;
utchr = utchour;
intz = lochr - utchr;

if (intz == -12) {intz = 12;}
if (intz == -13) {intz = 11;}
if (intz == -14) {intz = 10;}
if (intz == -15) {intz = 9;}
if (intz == -16) {intz = 8;}
if (intz == -17) {intz = 7;}
if (intz == -18) {intz = 6;}
if (intz == -19) {intz = 5;}
if (intz == -20) {intz = 4;}
if (intz == -21) {intz = 3;}
if (intz == -22) {intz = 2;}
if (intz == -23) {intz = 1;}
if (intz == -24) {intz = 0;}


Art.

AlexRoxUrSox
July 22nd, 2007, 13:33
This refers to getting the time for MapThis! from the PSP's XMB or what?

Art
July 22nd, 2007, 13:54
If Deniska wanted to, or anyone since the source is available I suppose,
the routine can be insterted to get the timezone the same way as my clock program.

The PSP knows the time and the timezone, the date and many other things,
so there's no need to get the user to define it in a config file.

Not a complaint, it's a picky thing really, but an easy fix.

Nieko
July 22nd, 2007, 21:23
Instead of using all those if-statements, you could also use this:


intz = (intz+24)%24;

Art
July 22nd, 2007, 23:45
What does it do exactly?
It causes an error if I compile it because the % sign defines 24 as binary
which the numbers 2 and 4 are invalid input for.

I got it down to this:


tzc = 12;
tzd = 12;

sceRtcGetCurrentClockLocalTime(&rtime); // calculate timezone
hhr = rtime.hour;
lochr = hhr;
sceRtcGetCurrentClock(&rtime,0);
utchour = rtime.hour;
utchr = utchour;
intz = lochr - utchr;

for (tzc=12; tzc<24; tzc++) {
if (intz == -tzc) {intz = tzd;}
tzd--;
} // tzc

Which is smaller space, but worse instruction time.
Art.

deniska
July 23rd, 2007, 02:17
how would I go about time in India? ;-)
they have their own timezone with 30 min diffrence from everyone else...

Art
July 23rd, 2007, 02:23
Change config file to:


Are you in India? Y/N

:D

Arxidon
July 23rd, 2007, 03:53
A 30 minute time difference wouldn't matter because the user already changed their time to adjust for the 30 minute difference in the psp.

Art
July 23rd, 2007, 04:14
It could still be worked out, yes, but deniska was looking at
a bug in my routine that uses integers, so it would
only give a result to the nearest hour, and be incorrect for India.
Is fixable though.

deniska
July 23rd, 2007, 04:31
A 30 minute time difference wouldn't matter because the user already changed their time to adjust for the 30 minute difference in the psp.
it would matter for mapThis! because it uses gmt time from gps and timezone offset to display correct "gps" time...

Nieko
July 23rd, 2007, 06:32
What does it do exactly?
It causes an error if I compile it because the % sign defines 24 as binary
which the numbers 2 and 4 are invalid input for.


It's supposed to do +24 (addition), then %24 (modulo), so that the range -12 to 11 becomes 12 to 35 first, then module 24 => range 0 to 23.

But in C things apparently don't work that easily, too bad...

AlexRoxUrSox
July 23rd, 2007, 07:39
I say the GPS time collaboration is pretty good already, but if your impatient and need the time in a second, then feel free to add the script.