Re: Real Time IO routines



On Sat, 27 Oct 2007 08:56:42 GMT, anon wrote:

function To_Duration is new Ada.Unchecked_Conversion
( Time, Duration ) ;

That is a bad idea. You don't know what is the internal representation of
Time. The intended effect can be achieved legally:

with Ada.Real_Time; use Ada.Real_Time;
with Ada.Text_IO; use Ada.Text_IO;

procedure Test is
function Image (T : Time) return String is
Seconds : Seconds_Count;
Fraction : Time_Span;
begin
Split (T, Seconds, Fraction);
declare
After : constant String :=
Duration'Image (To_Duration (Fraction));
begin
return Seconds_Count'Image (Seconds) & After (2..After'Last);
end;
end Image;
begin
delay 0.5;
Put_Line (Image (Clock) & "s since the epoch");
delay 0.5;
Put_Line (Image (Clock) & "s since the epoch");
end Test;

--------------------
However it is quite useless to output absolute time values involving an
unknown epoch. Unfortunately there is no portable way I know of to convert
Real_Time.Time to UTC.

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
.