Is there a way to get the current date in Ada ?
I'm looking for an equivalent to the C# DateTime.Now() returning a Duration.
I have an event T and I want to mesure if T started more than 30 seconds ago.
Is there a way to get the current date in Ada ?
I'm looking for an equivalent to the C# DateTime.Now() returning a Duration.
I have an event T and I want to mesure if T started more than 30 seconds ago.
You might want to take a look at the Clock function in the package Ada.Real_Time (see also ARM D.8).
The way to do this in Ada, is to use Ada.Calendar, which provides a Clock function returning the current Time:
declare
use type Ada.Calendar.Time;
Now : constant Ada.Calendar.Time := Ada.Calendar.Clock;
Interval : constant Duration := 30.0;
begin
if Now > Start_Time_Of_T + Interval then
Ada.Text_IO.Put_Line("Event T took too long");
end if;
end;
Depending on the required precision, you could look at the Ada.Real_Time package
instead. (The usage is similar, but would required a conversion from Duration to Time_Span)