DataMuseum.dk

Presents historical artifacts from the history of:

Rational R1000/400 Tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Rational R1000/400 Tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: B T

⟦4f2f0186c⟧ TextFile

    Length: 7289 (0x1c79)
    Types: TextFile
    Names: »B«

Derivation

└─⟦180fe333a⟧ Bits:30000405 8mm tape, Rational 1000, SW CATALOG, 10_20_0
└─⟦180fe333a⟧ Bits:30000537 8mm tape, Rational 1000, SW Catalog 10_20_0
    └─⟦5cb1d1d7f⟧ »DATA« 
        └─⟦3b1ee7bd8⟧ 
            └─⟦this⟧ 

TextFile

with Text_Io, Calendar;

---------------------------
package body Time_Library_1 is
    ---------------------------

    --| Overview
    --| TimeLib contains procedures and functions for getting, putting,
    --| and calculating times, and dates. It augments the
    --| predefined library package Calendar to simplify IO and provide
    --| additional time routines common to all Ada Test and Evaluation
    --| Tool Set (ATETS) tools.

    --| Requires
    --| All procedures and functions that perform IO use the
    --| predefined library package Text_IO and require that the
    --| specified file be opened by the calling program prior to use.
    --| All times and durations must be of types declared in the
    --| predefined library package Calendar.

    --| Errors
    --| No error messages or exceptions are raised by any of the TimeLib
    --| procedures and functions. However, any Text_IO and Calendar
    --| exceptions that may be raised are allowed to pass, unhandled,
    --| back to the calling program.

    --| N/A:  Raises, Modifies

    --  Version         : 1.1
    --  Author          : Jeff England
    --  Initial Release : 05/19/85
    --  Last Modified   : 06/07/85


    package Time_Io is new Text_Io.Fixed_Io (Calendar.Day_Duration);
    package Int_Io is new Text_Io.Integer_Io (Integer);

    Timing_Method : Timing_Type := Wall_Clock;
    --| When Timing_Method = WALL_CLOCK then Put_Time
    --| puts the time to the file in the form HH:MM:SS:FF.
    --| When Timing_Method = RAW the time put using
    --| Fixed_IO(Day_Duration).


    ----------------
    function Convert ( --| Convert an integer to a string
                      Input_Number : in Integer;
                      Width : in Integer := 0) return String is

        --| Effects:
        --| Converts an integer to a string of length Width. If the
        --| number if digits in Input_Number is less than Width then
        --| the digits are right justified in the output string and
        --| filled with zeros (0) on the left.

        Temp_Text : String (1 .. 16);
        Index : Integer;


    begin

        Int_Io.Put (Temp_Text, Input_Number);
        if Width <= 0 then
            Index := Temp_Text'Last;
            for I in Temp_Text'Range loop
                if Temp_Text (I) /= ' ' then
                    Index := I;
                    exit;
                end if;
            end loop;
        else
            Index := Temp_Text'Last - Width + 1;
            for I in Index .. Temp_Text'Last loop
                if Temp_Text (I) = ' ' then
                    Temp_Text (I) := '0';
                end if;
            end loop;
        end if;
        return Temp_Text (Index .. Temp_Text'Last);

    end Convert;


    -----------------
    function Fraction ( --| returns the fraction portion of the time in seconds
                       Seconds : Calendar.Day_Duration) return String is

        Temp_Secs : String (1 .. 10);

    begin
        Time_Io.Put (Temp_Secs, Seconds, 2, 0);
        return Temp_Secs (Temp_Secs'Last - 2 .. Temp_Secs'Last);
    end Fraction;


    ----------------
    function Date_Of ( --| Convert the date to a string
                      Date : Calendar.Time    --| The date to be converted
                      ) return String is

        --| Effects
        --| Converts the date to a string in the format MM/DD/YY

        --| N/A:  Raises, Requires, Modifies, Errors

        Year : Calendar.Year_Number;
        Month : Calendar.Month_Number;
        Day : Calendar.Day_Number;
        Seconds : Calendar.Day_Duration;

    begin

        Calendar.Split (Date, Year, Month, Day, Seconds);
        return Convert (Integer (Month), 2) & "/" & Convert (Integer (Day), 2) &
                  "/" & Convert (Integer (Year mod 100), 2);

    end Date_Of;



    ----------------------
    function Wall_Clock_Of ( --| Convert seconds to wall clock time
                            Seconds : Calendar.Day_Duration  --| The time to be converted
                            ) return String is

        --| Effects
        --| Converts the time of day or elapsed time, in seconds,
        --| to a string in the format HH:MM:SS.FF.

        --| N/A:  Raises, Requires, Modifies, Errors

        use Calendar;  -- For "-" of times and durations

        Half_Second : Day_Duration := 0.5;

    begin

        if Seconds < Half_Second then
            Half_Second := 0.0;
        end if;

        return Convert (Integer (Seconds - Half_Second) / 3600, 2) & ":" &
                  Convert ((Integer (Seconds - Half_Second) mod 3600) / 60, 2) &
                  ":" & Convert (Integer (Seconds - Half_Second) mod 60, 2) &
                  Fraction (Seconds);

    end Wall_Clock_Of;


    -------------------------
    procedure Put_Time_Of_Day
                 ( --| Put the time of day to the file
                  Fyle : in Text_Io.File_Type;           --| The output file
                  Seconds : in Calendar.Day_Duration  --| The time to be output
                  ) is

        --| Effects
        --| If Timing = WALL_CLOCK then the time is put to the file in the
        --| format HH:MM:SS.FF. If Timing = RAW then the time of
        --| day is put to the file using new Fixed_IO( Day_Duration ).
        --|
        --| Requires
        --| Fyle must have been previously opened by the calling program.

        --| N/A:  Raises, Modifies, Errors


    begin

        if Timing_Method = Wall_Clock then
            Text_Io.Put (Fyle, Wall_Clock_Of (Seconds));
        else
            Time_Io.Put (Fyle, Seconds, 0, 2, 0);
        end if;

    end Put_Time_Of_Day;


    ------------------
    procedure Put_Time ( --| Put the time to the file
                        Fyle : in Text_Io.File_Type;     --| The output file
                        Date : in Calendar.Time       --| The time to be output
                        ) is

        --| Effects
        --| If Timing = WALL_CLOCK then the time is put to the file in the
        --| format MM/DD/YYYY HH:MM:SS.FF. If Timing = RAW then the time of
        --| day is put to the file using new Fixed_IO( Day_Duration ).
        --|
        --| Requires
        --| Fyle must have been previously opened by the calling program.

        --| N/A:  Raises, Modifies, Errors


    begin

        Text_Io.Put (Fyle, Date_Of (Date));

        Text_Io.Put (Fyle, ' ');

        Put_Time_Of_Day (Fyle, Calendar.Seconds (Date));

    end Put_Time;


    --------------------
    procedure Set_Timing
                 ( --| Set the method of recording timing data

                  Timing :
                  Timing_Type  --| The type of timing data to be recorded

                  ) is

        --| Effects
        --| Sets th method of recording timing data to either RAW or Wall_Clock.
        --| If Timing = WALL_CLOCK then the time is put to the file in the
        --| format MM/DD/YYYY HH:MM:SS.FF. If Timing = RAW then the time of
        --| day is put to the file using new Fixed_IO( Day_Duration ).
        --| Overhead for either method may vary from system to system.

        --| N/A:  Raises, Requires, Modifies, Errors

    begin

        Timing_Method := Timing; --| Set timing method to RAW or WALL_CLOCK

    end Set_Timing;

end Time_Library_1;