SRL Archive - FAQ

OS Time


anonymity

2010-05-26 17:08:10

////////////////////
//
[Resolved] //
///////////////////


Is there a way to request for or get the computer (current local) time.

ex: I want to say:
- the script started running at "x in the morning"
- the script is doing alt-procedure at "y in the day"
- the script ran failsafes and is ending at "z in the after noon"
- total run time = (whatever the total run time is…)

Thanks for your time.

JPHamlett

2010-05-26 17:28:24

if getsystemtime =

or while getsystemtime <> xinthemorning do
wait(1);


not sure if itll work

Wizzup?

2010-05-26 17:32:07


program new;
var
y,m,d:word;
begin
decodedate(date,y,m,d);
writeln([y,m,d]);
end.

That's for dates. I think SRL has functions for time.
Total run time, use GetTimeRunning.

Narcle

2010-05-26 17:43:08


procedure TheTimeIs;
var
H, M, S, ms: Word;
begin
DecodeTime(Now, H, M, S, ms);
Writeln(inttostr(h)+':'+inttostr(m)+':'+inttostr(s)+':'+inttostr(ms))
end;

Returns the Clock time on your computer. Its in military time.

i luffs yeww

2010-05-27 01:33:07

^ Non-military time!


procedure TheTimeIs;
var
h, m, s, ms: Word;
begin
DecodeTime(Now, h, m, s, ms);
if(h > 12)then
h := h - 12;
Writeln(IntToStr(h) + ':' + IntToStr(m) + ':' + IntToStr(s));
end;

Daniel

2010-05-27 02:34:52

From: Narcle
Returns the Clock time on your computer. Its in military time.


*24-hour format/time. ;)

Drakan

2010-05-27 09:07:40

[QUOTE=Dan's The Man;713027]*24-hour format/time. ;)[/QUOTE]

^.^ just multiply by 24 :P

anonymity

2010-05-27 12:13:39

From: Wizzup?

program new;
var
y,m,d:word;
begin
decodedate(date,y,m,d);
writeln([y,m,d]);
end.

That's for dates. I think SRL has functions for time.
Total run time, use GetTimeRunning.

* Not my question, but that was going to be my next question. And thus proves your ability to read minds…
From: Narcle

procedure TheTimeIs;
var
H, M, S, ms: Word;
begin
DecodeTime(Now, H, M, S, ms);
Writeln(inttostr(h)+':'+inttostr(m)+':'+inttostr(s)+':'+inttostr(ms))
end;

Returns the Clock time on your computer. Its in military time.

That should do it. Thanks a bunch!

anonymity

2010-06-04 18:47:14

[Warning!] Double Post.. [/Warning]

////////////////////
//
[Part Two!] //
///////////////////


~tImIng Is EvErythIng~

Basically, I took the stuffs provided above, gargled, and vomited it back up. Thanks go to Wizzup? and Narcle. i luffs yeww was helpful, just not what I needed.
Procedure TimeOfDay;
var
H, M, S, MS: Word;
begin
DecodeTime(Now, H, M, S, MS);
Case H of
0..9: Writeln('0' + inttostr(h) + ':' + inttostr(m) + '(' + inttostr(s) + ')');
10..23: Writeln(inttostr(h) + ':' + inttostr(m) + '(' + inttostr(s) + ')');
end;
end;
^ Just to add the beginning zero to the time (I need it for my purpose..).

Procedure DateOfYear;
var
y, m, d : Word;
begin
DecodeDate(date, y, m, d);
case m of
1: Writeln('Jan/' + inttostr(d) + '/' + inttostr(y));
2: Writeln('Feb/' + inttostr(d) + '/' + inttostr(y));
3: Writeln('Mar/' + inttostr(d) + '/' + inttostr(y));
4: Writeln('Apr/' + inttostr(d) + '/' + inttostr(y));
5: Writeln('May/' + inttostr(d) + '/' + inttostr(y));
6: Writeln('June/' + inttostr(d) + '/' + inttostr(y));
7: Writeln('July/' + inttostr(d) + '/' + inttostr(y));
8: Writeln('Aug/' + inttostr(d) + '/' + inttostr(y));
9: Writeln('Sep/' + inttostr(d) + '/' + inttostr(y));
10: Writeln('Oct/' + inttostr(d) + '/' + inttostr(y));
11: Writeln('Nov/' + inttostr(d) + '/' + inttostr(y));
12: Writeln('Dec/' + inttostr(d) + '/' + inttostr(y));
end;
end;
^ I like the way this looks in the debug box best so far.

This next part I wasn't sure if both worked 100% because I haven't had scripts running for more than 20 hours since I started this thread…
v


Procedure ScriptRunTime1;
var
S, M, H, H2, D : integer;
begin
if GetTimeRunning < 86400000 then
begin
ConvertTime(GetTimeRunning, H, M, S);
Writeln('ran for ' + IntToStr(H) + ' hours, ' + IntToStr(M) + ' minutes, ' + IntToStr(S) + ' seconds');
end else;
if GetTimeRunning > 86399999 then
begin
ConvertTime(GetTimeRunning, H, M, S);
D:= 0;
repeat
H2:= H-24;
D:= D + 1;
until(H2 < 24);
Writeln('ran for ' + IntToStr(D) + ' days, ' + IntToStr(H2) + ' hours, ' + IntToStr(M) + ' minutes, ' + IntToStr(S) + ' seconds');
end;
end;

Procedure ScriptRunTime2;
var
S, M, H, D : integer;
begin
if GetTimeRunning < 86400000 then
begin
ConvertTime(GetTimeRunning, H, M, S);
Writeln('ran for ' + IntToStr(H) + ' hours, ' + IntToStr(M) + ' minutes, ' + IntToStr(S) + ' seconds');
end else;
if GetTimeRunning > 86399999 then
begin
ConvertTime(GetTimeRunning, H, M, S);
Writeln('ran for ' + IntToStr(D) + ' days, ' + IntToStr(H) + ' hours, ' + IntToStr(M) + ' minutes, ' + IntToStr(S) + ' seconds');
end;
end;

And now….
v

//Just examples of use..
Begin
SetupSRL;
Writeln('... ... ... ...');
Writeln('anonymous script started:');
DateOfYear;
TimeOfDay;
Writeln('... ... ... ...');
{
start my stuff;
check for stuffs;
begin pwning jagex;
oh no error..
DateOfYear;
TimeOfDay;
ScriptRunTime;
et cetera..
}
end;

So, that is that. Thanks again Wizzup? and Narcle for the timely response(s). Any suggestions would be welcomed; unless of course, I decide otherwise, and in that case I reserve full right to shoot down thoughts, ideas, and morale…

Narcle

2010-06-04 19:33:04

Try these slightly simplified / shortened

Procedure DateOfYear;
var
y, m, d : Word;
months: TStringArray;
begin
months := ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'June', 'July', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
DecodeDate(date, y, m, d);
Writeln(months[m-1]+'/' + inttostr(d) + '/' + inttostr(y));
end;


Procedure ScriptRunTime;
var
S, M, H, D : integer;
begin
if GetTimeRunning < (24*60*60*1000) then
begin
ConvertTime(GetTimeRunning, H, M, S);
Writeln('ran for ' + IntToStr(H) + ' hours, ' + IntToStr(M) + ' minutes, ' + IntToStr(S) + ' seconds');
end else
begin
ConvertTime(GetTimeRunning, H, M, S);
D := Floor(H/24);
H := H mod 24;//remainder
Writeln('ran for ' + IntToStr(D) + ' days, ' + IntToStr(H) + ' hours, ' + IntToStr(M) + ' minutes, ' + IntToStr(S) + ' seconds');
end;
end;

anonymity

2010-06-29 15:47:38

Continuation of the topic, little different thought though.

I notice that when I run Time of Day procedures. It renders the minute exactly as it is. I can explain with example:
H:M.S
12:32.4
14:5.31 <— there is no 0 before the 5.. this only occurs for 9 minutes out of every hour.

I was going through the SRL timing goodies and I could not find a place to make changes to do something like… (Sorry for the crappy code.)
Procedure TimeOfDay;
var
H, M, S, MS: Word;
begin
DecodeTime(Now, H, M, S, MS);
Case H of
0..9: Case M of
0..9: Writeln('0' + inttostr(H) + ':0' + inttostr(M) + '(' + inttostr(S) + ')');
10..59: Writeln('0' + inttostr(H) + ':' + inttostr(M) + '(' + inttostr(S) + ')');
end;
10..23: Case M of
0..9: Writeln(inttostr(H) + ':0' + inttostr(M) + '(' + inttostr(S) + ')');
10..59: Writeln(inttostr(H) + ':' + inttostr(M) + '(' + inttostr(S) + ')');
end;
end;
end;
^ I am mostly talking about the case of m. The case of h I do also, but just to make the time more standard.

I was curious to a function addition/change to the SRL timing to implement the '0' for those nine minutes.

i luffs yeww

2010-06-29 21:51:17

:D Zephypoo fixed this for me.

Change it to PadZ(H, 2) (PadZ(M, 2), PadZ(S, 2), PadZ(MS, 2), as well :)). No need for cases.

anonymity

2010-07-02 13:30:46

^ Yay, for the win. Thanks Zeph/luffs!
Function TimeOfDay: string;
var
H, M, S, MS: Word;
begin
DecodeTime(Now, H, M, S, MS);
Result := (Padz(IntToStr(H), 2) + ':' + Padz(IntToStr(M), 2) + '.' + Padz(IntToStr(S), 2));
end;
^ Basic military (x24) time.

As always thanks to all. Also RsN & Ron.

Nava2

2010-07-02 23:58:25

FYI, a lot of this stuff is in SRL, Timing.scar :)

anonymity

2010-07-03 01:07:46

Yea, I found this out after I went :duh: because I didn't :google: like :norris:. All this true, I just don't like how some of the stuff works. So, I shortened or made work for me. Thanks though. If I make changes in the SRL includes folder, will it be reverted back if I use sex?

i luffs yeww

2010-07-07 03:45:19

^ Yes.