Time¶
Time related misc functions, constants and variables.
Time constants¶
This section is about the time constants WaspLib provides so you have an easier time specifying human friendly units of time since Simba works in milliseconds.
TICK const¶
Represents a game tick worth of time (600 milliseconds).
For example, if you wanted to sleep for 6 game ticks you could do this:
{$I WaspLib/main.simba}
begin
Sleep(6*TICK);
end.
SECOND const¶
Represents one second worth of time in milliseconds (1000 milliseconds).
For example, if you wanted to sleep for 33 seconds you could do this:
{$I WaspLib/main.simba}
begin
Sleep(33*SECOND);
end.
MINUTE const¶
Represents one minute worth of time in milliseconds (60000 milliseconds).
For example, if you wanted to sleep for 12 minutes you could do this:
{$I WaspLib/main.simba}
begin
Sleep(12*MINUTE);
end.
HOUR const¶
Represents one hour worth of time in milliseconds (3600000 milliseconds).
For example, if you wanted to sleep for 4 hours you could do this:
{$I WaspLib/main.simba}
begin
Sleep(4*HOUR);
end.
DAY const¶
Represents one day worth of time in milliseconds (86400000 milliseconds).
For example, if you wanted to sleep for 7 days you could do this:
{$I WaspLib/main.simba}
begin
Sleep(7*DAY);
end.
Date format constants¶
Date format strings ready to use with some popular date formatting schemes.
DT_FORMAL_DATE const¶
Formal date format YYYY years, M months and D days for TDateTime
Example:
{$I WaspLib/main.simba}
begin
WriteLn TDateTime.CreateFromSystem().ToString(DATE_FORMAL);
end.
Which should print something like this:
2026 years, 6 months and 14 days
MS_DATE_FORMAL const¶
Formal date format YYYY years, M months and D days for FormatMilliseconds
Example:
{$I WaspLib/main.simba}
begin
WriteLn FormatMilliseconds(900*DAY, MS_DATE_FORMAL);
end.
Which should print something like this:
2 years, 5 months and 17 days
DT_SHORT_DATE const¶
Short date format DD/MM/YYYY.
Example:
{$I WaspLib/main.simba}
begin
WriteLn TDateTime.CreateFromSystem().ToString(DT_SHORT_DATE);
end.
Which should print something like this:
14/06/2026
MS_DATE_SHORT const¶
Short date format DD/MM/YYYY for FormatMilliseconds.
Example:
{$I WaspLib/main.simba}
begin
WriteLn FormatMilliseconds(900*DAY, MS_DATE_SHORT);
end.
Which should print something like this:
17/05/02
DT_SHORT_DATE_R const¶
Reversed short date format YYYY/MM/DD for TDateTime.
Example:
{$I WaspLib/main.simba}
begin
WriteLn TDateTime.CreateFromSystem().ToString(DT_SHORT_DATE_R);
end.
Which should print something like this:
2026/06/14
MS_DATE_SHORT_R const¶
Short date format YYYY/MM/DD for FormatMilliseconds.
Example:
{$I WaspLib/main.simba}
begin
WriteLn FormatMilliseconds(900*DAY, MS_DATE_SHORT_R);
end.
Which should print something like this:
02/05/17
Time format constants¶
Time format strings ready to use with some popular time formatting schemes.
DT_TIME_FORMAL const¶
Formal time format HH hours, MM minutes and SS seconds for TDateTime.
Example:
{$I WaspLib/main.simba}
begin
WriteLn TDateTime.CreateFromSystem().ToString(DT_TIME_FORMAL);
end.
Which should print something like this:
13 hours, 40 minutes and 50 seconds
MS_TIME_FORMAL const¶
Formal time format HH hours, MM minutes and SS seconds for FormatMilliseconds.
Example:
{$I WaspLib/main.simba}
begin
WriteLn FormatMilliseconds(32*DAY+15*MINUTE+12*SECOND, MS_TIME_FORMAL);
end.
Which should print something like this:
768 hours, 15 minutes and 12 seconds
TIME_SHORT const¶
Short, 24H time format HH:MM:SS for both TDateTime and FormatMilliseconds.
Example:
{$I WaspLib/main.simba}
begin
WriteLn TDateTime.CreateFromSystem().ToString(TIME_SHORT);
end.
Which should print something like this:
13:40:50
DT_MINUTES_FORMAL const¶
Formal time format for minutes and seconds MM minutes and SS seconds for
TDateTime.
Example:
{$I WaspLib/main.simba}
begin
WriteLn TDateTime.CreateFromSystem().ToString(DT_MINUTES_FORMAL);
end.
Which should print something like this:
48 minutes and 59 seconds
MS_MINUTES_FORMAL const¶
Formal time format for minutes and seconds MM minutes and SS seconds for
FormatMilliseconds.
Example:
{$I WaspLib/main.simba}
begin
WriteLn FormatMilliseconds(3*HOUR+15*SECOND, MS_MINUTES_FORMAL);
end.
Which should print this:
180 minutes and 15 seconds
FILE_TIME_FORMAT const¶
Date and time format for file names YYYY-MM-DD_hh-mm-ss-ms for both TDateTime and
FormatMilliseconds.
Example:
{$I WaspLib/main.simba}
begin
WriteLn TDateTime.CreateFromSystem().ToString(FILE_TIME_FORMAT);
end.
Which should print something like this:
2026-06-14_13-50-14-614
This can be useful when you need unique file names and unless you try to create the same file twice in the same millisecond this will give you a unique name for it, for example:
{$I WaspLib/main.simba}
var
img: TImage;
filename: String;
begin
img := Target.GetImage();
filename := TDateTime.CreateFromSystem().ToString(FILE_TIME_FORMAT);
img.Save(filename + '.png', True);
end.
TCountDown.Restart¶
procedure TCountDown.Restart(min, max: Integer); overload;
Restarts the TCountDown with a random value between min and max