clock.inc

For questions relating to POL scripting (not necessarily related to WoD)

Moderators: Siobhan, Sebastian, Drocket

clock.inc

Postby Maximus on Sun Apr 11, 2004 10:50 pm

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.
Maximus
Newbie
 
Posts: 8
Joined: Sun Dec 22, 2002 4:48 am

Postby SDonald on Mon Apr 12, 2004 12:10 am

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.
SDonald
Regular Poster
 
Posts: 102
Joined: Fri Oct 11, 2002 7:47 am
Location: Australia

Postby Maximus on Mon Apr 12, 2004 11:25 pm

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
Maximus
Newbie
 
Posts: 8
Joined: Sun Dec 22, 2002 4:48 am

Postby SDonald on Tue Apr 13, 2004 7:16 am

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!
SDonald
Regular Poster
 
Posts: 102
Joined: Fri Oct 11, 2002 7:47 am
Location: Australia

Postby Maximus on Sun Apr 18, 2004 8:26 am

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.
Maximus
Newbie
 
Posts: 8
Joined: Sun Dec 22, 2002 4:48 am

Postby SDonald on Sun Apr 18, 2004 10:53 am

Well, thanks for helping me understand how the function worked.
SDonald
Regular Poster
 
Posts: 102
Joined: Fri Oct 11, 2002 7:47 am
Location: Australia

Postby Drocket on Mon Apr 19, 2004 4:25 am

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...
Drocket
Site Admin
 
Posts: 820
Joined: Mon Oct 07, 2002 2:54 am

Postby Maximus on Mon Apr 19, 2004 8:25 pm

Drocket I never thought about daylight savings time. Thanks for the insight.
Maximus
Newbie
 
Posts: 8
Joined: Sun Dec 22, 2002 4:48 am


Return to Scripting Forum

Who is online

Users browsing this forum: No registered users and 1 guest

cron