Page 1 of 1

clock.inc

PostPosted: Sun Apr 11, 2004 10:50 pm
by Maximus
Code: Select all
///////////////////
//  Figures out what the current hour is, military time (real-world time)
///////////////////

function Systime_GetHour ()
   var systime := polcore().systime;
   //convert to GMT
//   systime := systime + 43200;
   systime := CINT (systime % SECONDS_PER_DAY);
   var hour := CINT (systime / 3600);
   return hour;
endfunction


Excuse my newbiness

How do I change this to show GMT -6 time

Thanks.

PostPosted: Mon Apr 12, 2004 12:10 am
by SDonald
I can't actually find where polcore().systime is documented, but it appears to return gmt from the server if it is set to the correct timezone.

Untested, but have you tried simply adjusting the systime by 6 hours?

old code:
// systime := systime + 43200;

new code:
systime := systime - 21600;


for all instances in clock.inc

It would be interesting to see if that produces totally crazy numbers for the time eg in the server stats page on the internal web.

PostPosted: Mon Apr 12, 2004 11:25 pm
by Maximus
ok i tried the new code

systime := systime - 21600;


this is the result


Apr 12, 2034 23:18GMT


my actual time is
Apr 12, 2004 18:20GMT

PostPosted: Tue Apr 13, 2004 7:16 am
by SDonald
Now that's what I call a timewarp... 20 years! :D
Obviously it's not seconds we adjusted (21600 seconds being 6 hours)

Sorry it didn't help.. but looks like it adjusts SOMETHING!

PostPosted: Sun Apr 18, 2004 8:26 am
by Maximus
systime := systime - 18200; (-5 hrs)

This got the time I needed.

The other one that I adjusted was for years.

I could have swore that Missouri was -6, oh well it is working now.

Thanks for the help.

PostPosted: Sun Apr 18, 2004 10:53 am
by SDonald
Well, thanks for helping me understand how the function worked.

PostPosted: Mon Apr 19, 2004 4:25 am
by Drocket
Maximus: the one hour difference you noticed is probably due to daylight savings time. I think the POL clock is based on 'real' time, and doesn't take into effect (stupid) short-term variations in time.

As for how its works, I'm a bit vague about it myself (and yes, I wrote it :) ) It was a horrible mess to get working right...

PostPosted: Mon Apr 19, 2004 8:25 pm
by Maximus
Drocket I never thought about daylight savings time. Thanks for the insight.