I am working with 2 virtual machines (VMWare); One VM has GNATPro Ada compiler 7.3.2 and Ada.Real_Time.Clock returns the number of seconds since the beginning of the epoch as expected. The other VM has GNATPro 19.0 and Ada.Real_Time.Clock returns the number of seconds since the VM Started.
We are using Ada 95 on both VMs.
I have checked that the time setting on both virtual machines are the same.
To check that it was a compiler difference I compiled a small test program on Gnat Pro 19.0 and ran it on the virtual machine with the older compiler. I got the same results as I did on the VM with newer version of the compiler. I then compiled the test program with the older compiler and ran it on the VM with the newer compiler and got the same results as on the VM with the older compiler.
My question is does anyone have any idea how I can get the Ada.Real_Time.Clock to return the number of seconds from the start of the epoch for GNATPro 19.0
Below is the test program.
with Test_Io;
with Ada.Real_Time;
procedure Time_Test is
   Current_Real_Time : Ada.Real_Time.Time;
   Time_Span : Ada.Real_Time.Time_Span;
   Seconds_Count : Ada.Real_Time.Seconds_Count;
begin
    Current_Real_Time := Ada.Real_Time.Clock;
    Ada.Real_Time.Split (
             T => Current_Real_Time,
             Sc => Seconds_Count,
             Ts => Time_Span);
   Test_Io.Put_Line("TRACE: Seconds_Count = " & Seconds_Count'Img);
end Time_Test;
                The RM D.8 says:
"The Time value I represents the half-open real time interval that starts with E+I*Time_Unit and is limited by E+(I+1)*Time_Unit, where Time_Unit is an implementation-defined real number and E is an unspecified origin point, the epoch, that is the same for all values of the type Time. It is not specified by the language whether the time values are synchronized with any standard time reference. [For example, E can correspond to the time of system initialization or it can correspond to the epoch of some time standard.]"
So the implementation is free to chose any epoch it wants.
When you say "the epoch" I assume you have a specific value in mind? UNIX-time? You might be better off with Ada.Calendar.Time for wall-clock behaviour.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With