Systime is wrong?

Get Help on scripting in POL with configurations, config setups, script trouble shooting, etc.
Post Reply
epsilon
New User
Posts: 18
Joined: Wed Mar 31, 2010 12:30 am

Systime is wrong?

Post by epsilon »

I have a problem, my pol systime is totally wrong, it thinks its 1970 something...

What could that be due to? And how to fix.
guialtran
Grandmaster Poster
Posts: 120
Joined: Wed Jul 30, 2008 12:42 pm

Re: Systime is wrong?

Post by guialtran »

is using a standard in many languages

http://java.sun.com/j2se/1.4.2/docs/api ... /Date.html

"Date(long date) Allocates a Date object and initializes it to represent the specified number of milliseconds since the standard base time known as "the epoch", namely January 1, 1970, 00:00:00 GMT."



old script.
can be used in an include "function"
or command point "program"

Code: Select all

use os;
use uo;

program date(character)
var year := {2678400,2419200,2678400,2592000,2678400,2592000,2678400,2678400,2592000,2678400,2592000,2678400};
var leap_year := {2678400,2505600,2678400,2592000,2678400,2592000,2678400,2678400,2592000,2678400,2592000,2678400};
var date := struct{"second":=0,"minute":=0,"hour":=0,"day":=1,"month":=1,"year":=1970};
var time := polcore().systime;
//time := time - 3*60*60; com Fuso horário do brasil + 3 horas
var quociente := cint(time / 126230400);// 126230400 é igual a 3 anos normais + 1 bissexto, transformados em segundos
time := ( time - ( quociente * 126230400 )) ;// time = quantos 4 anos cabem no total
date.year := ( date.year + quociente*4 );
while(time >= 31536000)
    if(date.year % 4 == 0)
        date.year := ( date.year + 1 );
        time := ( time - 31622400 );
    else
        date.year := ( date.year + 1 );
        time := ( time - 31536000 );
    endif
endwhile
if(date.year % 4 == 0)
    while(time >= leap_year[date.month] )
        time := ( time - leap_year[date.month] );
        date.month := ( date.month + 1 );
    endwhile
else
    while(time >= year[date.month] )
        time := ( time - year[date.month] );
        date.month := ( date.month + 1 );
    endwhile
endif

quociente := cint( time / 86400 );
time := ( time - ( quociente * 86400 )) ;
date.day := (date.day + quociente );
quociente := cint( time / 3600 );
time := ( time - ( quociente * 3600 )) ;
date.hour := (date.hour + quociente );
quociente := cint( time / 60 );
date.minute := (date.minute + quociente );
date.second := ( time - ( quociente * 60 )) ;

SendSysMessage( character," Clock  "+date.hour+":"+date.minute+":"+date.second, 3, 33 );
SendSysMessage( character," Date "+date.month+"/"+date.day+"/"+date.year, 3, 33 );

endprogram
epsilon
New User
Posts: 18
Joined: Wed Mar 31, 2010 12:30 am

Re: Systime is wrong?

Post by epsilon »

Well the problem is that is was working properly, and for no reason just stopped working and reset to 1970 something. Is it the core that handles it? Because I haven't found an actual function for the pol.systime().
Turley
POL Developer
Posts: 670
Joined: Sun Feb 05, 2006 4:45 am

Re: Systime is wrong?

Post by Turley »

PolCore().systime is a direct interface for time(NULL). So you should check your system.
epsilon
New User
Posts: 18
Joined: Wed Mar 31, 2010 12:30 am

Re: Systime is wrong?

Post by epsilon »

Turley wrote:PolCore().systime is a direct interface for time(NULL). So you should check your system.
That's the strange thing. The system clock is fine, but the polcore time is all messed.

I am using the old 095 core though.
Gnafu
Grandmaster Poster
Posts: 136
Joined: Thu Feb 02, 2006 7:29 am

Re: Systime is wrong?

Post by Gnafu »

Are you running pol (32bit) on a 64bit host?
Maybe (maybe) the system is representing the time with too much bytes and pol can't understand it properly.
Just guessing.
epsilon
New User
Posts: 18
Joined: Wed Mar 31, 2010 12:30 am

Re: Systime is wrong?

Post by epsilon »

Gnafu wrote:Are you running pol (32bit) on a 64bit host?
Maybe (maybe) the system is representing the time with too much bytes and pol can't understand it properly.
Just guessing.
Nope, seems to be a 32bit host.
Post Reply