SRL Archive - Bugs

GetSystemTime


Diddy Kong

2010-03-19 21:26:08

When I use GetSystemTime I get the wrong time.

Mr. Doctor

2010-03-19 21:33:58

From: Diddy Kong
When I use GetSystemTime I get the wrong time.


GetSystemTime is the time between when the script begins and ends. How could it be wrong?

E: Ohhh,

Starting
52966000 // 1 second?
Successfully executed.

Diddy Kong

2010-03-19 21:37:08

No, GetSystemTime does just exactly what it says.

Mr. Doctor

2010-03-19 21:39:35

Make your own TimeRunning?


begin
MarkTime(TimeRunning1);
....
If ... then
Writeln(' Ran for ' + IntToStr(TimeFromMark(TimeRunning1)));
end.

E: GAHH, I'm stupid. Thought you meant something for TimeRunning in Runescape. Sorry for my stupidity :p. Should have read more thoroughly. :l

Diddy Kong

2010-03-19 21:45:48

I will not have your incoherent posts in this thread no longer.

I say nothing about about script beginning and ending times; why did you even bring that up? GetSystemTime is not MarkTime.

Diddy Kong

2010-03-19 22:56:08

I'm not really sure. SCAR is giving me the same output, too. GetSystemTime is to get the current time for your computer in milliseconds, right?

senrath

2010-03-20 00:20:56

MarkTime is a wrapper for GetSystemTime.

And yes, GetSystemTime gets the current computer time in milliseconds.

Wanted

2010-03-20 02:16:51

From: Diddy Kong
When I use GetSystemTime I get the wrong time.


Lol!? What do you mean "the wrong time" it gives a huge integer that increases 1 every milisecond.

T := GetSystemTime;
Wait(9001);
WritenLn(GetSystemTime - T);

Wizzup?

2010-03-20 07:33:00


writeln(GetTimeRunning);

Diddy Kong

2010-03-20 08:58:22

Well then. Why do I get the wrong time with this function?

program new;

function LocalTime : String;
var
S, M, H, Mil : Integer;
StrResult : String;
begin
Mil := GetSystemTime
H := Floor(Mil / 1000 / 60 / 60)
Mil := Mil - H * 60 * 60 * 1000
M := Floor(Mil / 1000 / 60)
Mil := Mil - M * 60 * 1000
S := Floor(Mil / 1000)
Mil := Mil - S * 1000

if 10 > H then
StrResult := '0' + IntToStr(H) + ':'
else
StrResult := IntToStr(H) + ':';
if 10 > M then
StrResult := StrResult + '0' + IntToStr(M) + ':'
else
StrResult := StrResult + IntToStr(M) + ':';
if 10 > S then
StrResult := StrResult + '0' + IntToStr(S) + '.'
else
StrResult := StrResult + IntToStr(S) + '.';

case Length(IntToStr(Mil)) of
1 : StrResult := StrResult + '000' + IntToStr(Mil);
2 : StrResult := StrResult + '00' + IntToStr(Mil);
3 : StrResult := StrResult + '0' + IntToStr(Mil);
end;

Result := '[' + StrResult + '] '
end;

begin
While True do
begin
Writeln(LocalTime)
Wait(315);
end;
end.

Wizzup?

2010-03-20 08:59:46

Because you are still using GetSystemTime…?

Diddy Kong

2010-03-20 09:03:08

    Writeln(LocalTime)
Writeln(GetTimeRunning)
00:11:05.0141
1670
00:11:05.0469
1982
00:11:05.0796
2309
00:11:06.0124
2637
Successfully executed.

GetTimeRunning does not seem to get the time of my computer. Looks to me it just gets the amount of milliseconds the script has been running for.

mastaraymond

2010-03-20 09:50:59

GetSystemTime returns the current uptime time..

Use the 'now/date' function, it contains the current time.

EDIT: See SRL for the proper use of this functions.


{*******************************************************************************
function TheTime : string;
By: RsN (fixed by Ron)
Description: Returns current time as a string
*******************************************************************************}

function TheTime: string;
var
Hour, Mins, Sec, MSec: Word;
PAM: string;
begin
DecodeTime(Now, Hour, Mins, Sec, MSec);
PAM := 'AM';
if (Hour > 12) then
begin
Hour := Hour - 12;
PAM := 'PM';
end else if (Hour = 12) then
PAM := 'PM'
else if (Hour = 0) then
Hour := 12;
Result := (Padz(IntToStr(Hour), 2) + ':' + Padz(IntToStr(Mins), 2) + ':' + Padz(IntToStr(Sec), 2) + ' ' + PAM);
end;

{*******************************************************************************
function TheDate(DateFormat : Integer) : String;
By: Ron, Nava2 & Narcle
Description: TheDate will return the current date. DateFormats can be...
Date_Formal = April 2nd, 2007 Month Day, Year
Date_Month = 04/02/07 Month/Day/Year
Date_Day = 02-04-07 Day-Month-Year
*******************************************************************************}

function TheDate(DateFormat: Integer): string;
var
Year, Month, Day: Word;
D: string;
Mnths, sfx: TStringArray;
begin
DecodeDate(Date, Year, Month, Day);
Mnths := ['January', 'February', 'March', 'April', 'May', 'June', 'July',
'August', 'September', 'October', 'November', 'December'];
sfx := ['st', 'nd', 'rd'];
case DateFormat of
1:
begin
if InRange(Day mod 10, 1, 3) and not InRange(Day, 11, 13) then
D := sfx[(Day mod 10)-1]
else
D := 'th';
Result := Mnths[Month - 1] + ' ' + IntToStr(Day) + D +', ' + IntToStr(Year);
end;
2: Result := Padz(IntToStr(Month), 2) + '/' + Padz(IntToStr(Day), 2) + '/' + Copy(IntToStr(Year), 3, 4);
3: Result := Padz(IntToStr(Day), 2) + '-' + Padz(IntToStr(Month), 2) + '-' + Copy(IntToStr(Year), 3, 4);
else
srl_Warn('TheDate', 'DateFormat can only be 1, 2, or 3!', warn_AllVersions);
end;
end;