SRL Archive - OSR Help

Getting Time & Date.


mrpickle

2010-06-13 12:23:31

Is there a command for getting the time and date?



I only know of a GetSystemTime, which is not useful if you want to bots to do thing on a hourly basis :)

3Garrett3

2010-06-13 12:34:13

GetTimeRunning?

Or marktime in the beginning and do a check for "TimeFromMark" and if it's been an hour, do it.

I don't know if there is a specific command.

mrpickle

2010-06-13 15:26:00

that doesn't really work. There are some games where hourly events happen. It happens right on the dot every hour. I want the script to be able to know when that hour is no matter when I start the script.

something like. GetComputerTime. but of course I can't find a command like that.

3Garrett3

2010-06-13 15:56:13

I remember someone requesting this a while ago, searching the help section should get you what you're looking for.

I believe it had something to do with getting the time and date that the computer was set on.

Wanted

2010-06-13 16:04:50

{.include SRL\SRL.scar}

begin
SetUpSRL;
WriteLn(TheDate(1) + ' - ' + TheTime);
end.

i luffs yeww

2010-06-13 16:08:58

^ Shorter! :D


{$i SRL/SRL.scar}
begin
Writeln(TheDate(1) + ' - ' + TheTime);
end.

mrpickle

2010-06-13 16:36:13


I remember someone requesting this a while ago, searching the help section should get you what you're looking for.

I did search. but couldn't find that since I didn't know what to search for. "Date" and "time" are often used outside scripting.

But ^^ there it is. thanks you three for the input :) (though shorter like that might not be nessisary xD)

Wanted

2010-06-13 16:36:29

All you did is remove SetUpSRL

Which is not a good idea

i luffs yeww

2010-06-13 16:40:37

^ For that specific script it doesn't matter either way.

Wizzup?

2010-06-13 16:43:21

From: IceFire908
All you did is remove SetUpSRL

Which is not a good idea


And he used a proper pascal include directive. ;)

mrpickle

2010-06-13 16:44:56

just looked this up. More questions cause i'm going to take the function apart so i can use the values.xD



{*******************************************************************************
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;

What exactly is Padz?
What exactly is "Now"?
DecodeTime(Now, Hour, Mins, Sec, MSec);

anonymity

2010-06-13 16:56:53

Dunno if this is what you are looking for, but I had the same question a while back. Thanks to Wizzup? and Narcle I got a nice answer. Maybe this works for you.


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 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;