Re: Real Time IO routines
- From: "Dmitry A. Kazakov" <mailbox@xxxxxxxxxxxxxxxxx>
- Date: Sat, 27 Oct 2007 12:18:39 +0200
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
.
- Follow-Ups:
- Re: Real Time IO routines
- From: anon
- Re: Real Time IO routines
- References:
- Real Time IO routines
- From: andrew
- Re: Real Time IO routines
- From: anon
- Real Time IO routines
- Prev by Date: Re: Real Time IO routines
- Next by Date: Re: ASIS?
- Previous by thread: Re: Real Time IO routines
- Next by thread: Re: Real Time IO routines
- Index(es):